-
- Notifications
You must be signed in to change notification settings - Fork 6.9k
Description
To submit an ajax based form, we currently use the beforeSubmit method (from yii.activeForm.js) and submit using our own javascript. However, we also need to use enableAjaxValidation and generally set validationUrl.
This results in a double request - ie, one to validate the form and then a second request to submit the form resulting in slow user experience. I get yii.activeForm.js was written intended for manual browser (non-ajax) submissions (so this works fine for that use case).
For ajax submitted forms, why can't we just do one submission request? If 'errors' are returned, then we process those errors and validate the form, if not, its' a success and we handle it however we want based on the response.
Perhaps this leads to a bigger question, is it possible if not too complicated to consider an enableAjaxSubmission option for ajax based forms?
(As a side note, we tried to disable 'enableAjaxValidation' and hook into the updateMessages but that's not possible, enableAjaxValidation must be set to true for that to work.)