-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Html::error doesn't seems to be working on ajaxValidation or clientsidevalidation #9700
Comments
It should be active form error summary: http://www.yiiframework.com/doc-2.0/yii-widgets-activeform.html#errorSummary()-detail |
@samdark i don't want to display the error summary, i just want to display the error of a particular attribute say "username", which i am not able to find a way to achieve, 'help-block']); ?>is not working on ajaxValidation. errorSummary($model); ?> displays all the errors of the form, and why is this closed i wonder.. |
Client validation works with Active Form only so any A field for a single attribute rendered via http://www.yiiframework.com/doc-2.0/yii-widgets-activeform.html#field()-detail will display error for that attribute. |
@samdark: Yes it displaying error for that attribute, but only inline, that is below the field itself which i already know, but not at the top of the form.. my form with Ajax Validation (Read the comment please):
I think this is a general requirement, someone may want to display errors for certain attributes only or in my case only single attribute, and that too at the top of the form while using ajax validation, how do we achieve this in Yii 2.0, finding it hard..can you please suggest? |
Please use the forum for asking such questions, github is for bug and feature requests. |
@cebe Apologies, but it looked like a feature being ignored in yii 2.0 while it was there in yii 1.1..hence i raised this question here. Googled the same thing didn't found the solution for this. Updated the same already on different forums, but no one seems to have the answer. |
@drinkncode is that real requirement in your app to display error for exactly one field at the top of the form? |
@samdark Yes, i can even provide you an screenshot, we are already doing this in our web app which is on Yii 1.1..and this is not possible in Yii 2.0..Its designed that way, and now if its unavailable, that will be major design change for us, and like i said this can be a requirement for many.. |
Umm... but summary should work in this case. |
But summary doesn't accept any parameters, which can limit the errors to a particular attribute, like..
can we have this, and if nothing is passed it can show all the errors.. Or if possible please add method "error" back in the class ActiveForm.just like yii 1.1 used to have..this will be lot easier and helpful.. |
What if email is filled correctly but password isn't filled? |
It says "Email/Password can't be empty", which we show that to user by adding that error in "username" attribute..by the code below..
and if login credentials are wrong we display that using..
also when user clicks on forgot password we validate the username only and can display message for email only not for password. |
OK but then summary won't display multiple lines since there are no multiple errors... |
Ok here is the catch, there will always be two errors, when we have entered invalid email id or special characters or something else, i.e where errorSummary will display all at the same time, but this->error("username"), queue them and always display error at the 0 index, i.e first value of the array. |
If these are for the same attribute and you haven't touched |
It's a very bad idea to use one field error instead of summary. |
Hi, i have been shifting from yii 1.1 and yii 2.0, and i have to display my attribute error at the top of the form and no inline errors, but finding it hard to so, to achieve my requirement i tried putting below code at the top of my form:
'help-block']); ?>but it doesn't display any errors on ajaxValidation and clientValidation while on normal submit and validate it is showing up the error.
Am i doing something wrong or is there an alternative to achieve this or is this missed or left out?
The text was updated successfully, but these errors were encountered: