-
-
Notifications
You must be signed in to change notification settings - Fork 296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggestion: determine whether validation was successful in js activeform "afterValidate" event #167
Comments
Can't you check length of function (event, messages, errorAttributes) {
if (errorAttributes.length) {
// not valid
} else {
// valid
}
} |
That was what I initially tried, but it does not work, because
then Now, this would all sort of make sense, if we were dealing purely with client-side validation. After all, client-side does not know if there are any validation errors on the server-side... until you introduce AJAX validation! :) With AJAX validation, we do know if there were server-side validation errors, so we should be able to know if validation was successful in the |
According to code it should be available in AJAX validation as well. Please create a ticket in the main Yii 2.0 repo with a clear way to reproduce the issue. Thanks. |
Alright. In the meantime I have found a working solution. Turns out that
Usage example:
|
Great. Would you like to make a pull request adding it to recipe? |
Seems like a very trivial, common requirement, but there doesn't seem to be any simple way to know whether validation was successful inside the
afterValidate
client event. How do we do it?This would fit perfectly into the Forms activeform js chapter.
The text was updated successfully, but these errors were encountered: