yii2: 2.0.10 ActiveForm breaks form submission in certain instances
I recently upgraded to 2.0.10 and I noticed some weird behaviour with my form submissions; my forms would no longer submit unless I was submitting them via an AJAX procedure.
So I did some debugging, on all my non-ajax forms I have this binded to them…
$('form').not('.js-ajax').on('submit', function(e) {
// Disable submit button
$(e.target).find('button[type=submit], input[type=submit]').prop('disabled', true);
});
So as you can probably tell it disables the submit button when the user submits the form; if I comment out this code then the form will now submit; but the forms were submitting fine on 2.0.9 with this code enabled, which I confirmed by going back and forth between 2.0.9 and 2.0.10.
Now you ask what does this have to do with ActiveForm? Well this only happens on forms made with ActiveForm - I have a non-ajax form done without ActiveForm and it submits fine.
So, a summary:
2.0.10
Form submitted via AJAX: works Form made with ActiveForm with submit button disabling: Doesn’t work Form made with ActiveForm without submit button disabling: Works Form NOT made with ActiveForm: works
2.0.9 and below
All situations work
What steps will reproduce the problem?
Create standard and ActiveForm forms to test - test ActiveForm forms with and without submit button disabling on submit.
What is the expected result?
Form sbumits.
What do you get instead?
Forms you build with ActiveForm AND disable the submit button on submit don’t submit.
Additional info
| Q | A |
|---|---|
| Yii version | 2.0.10 |
| PHP version | 5.5.28 |
| Operating system | Win 7 |
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 1
- Comments: 19 (16 by maintainers)
Solution is by @SilverFire. I haven’t tested it myself…