How To Create A Client-Side Validation That Depends On Ajax Calls?

I’m creating a validation plugin that, in the client side, will need to run an ajax call and then call messages.push() in some error callbacks.

First I ran into the issue where the form was being submitted before the ajax call was completed, and I fixed that using async in the call.

Now I’m having a problem where the form is submitted even thought the error callbacks are called - as if the submission and the error callbacks were running at the same time, and then yiiactiveform could not see on time the new error messages.

Is there a way to make yiiactiveform wait until I say it’s ok to go ahead (like if I could say yiiactiveform.wait() in the beginning and yiiactiveform.done() inside the callbacks), or make those callbacks run smoothly in a synchronous fashion?

If you ever search for the subject and felt in this lonely topic, take a look at the solution I proposed here: https://github.com/yiisoft/yii/pull/3387