-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
CCompareValidator supports {compareAttribute} in $message only server-side (undocumented) and not on client side #1621
Comments
Really can't remember why I closed the #515 issue... @ErikMinekus is right in clientValidation compareValue gets the label instead of the value like on server-side, compareAttribute should be added for the client and it shoudl be mentioned in the documentation setting this to Easy Pick... |
CCompareValidator supported {compareAttribute} in $message only server-side
fixed with 54c71d5. |
Reopening since travis build failed: https://travis-ci.org/yiisoft/yii/jobs/3299637 |
But now compareAttribute and compareValue holds the same info - the label compareValue should hold the value |
Nope, this depends on whether you are comparing with a fixed value or with an other attribute. |
When you use |
check the line 163 -
we already have the JS code that gets the actual compareTo value. |
Sure, but we can not use strstr to get that value into the message. Do you have a solution how to do this in JS? |
…ame for CCompareValidator issue yiisoft#1621
finally fixed with #1740. Server and client messages are now the same. |
CCompareValidator->message should accept a {compareAttribute} placeholder for the name of the attribute it compares to.
Actually, it does (and this is not mentioned in the documentation) but only on server side validation.
Client side validation forgets to replace the {compareAttribute} placeholder.
Client side validation should always be absolutely identical to server side validation for all builtin validators.
Problem is in https://github.com/yiisoft/yii/blob/1.1.12/framework/validators/CCompareValidator.php#L207
I guess adding '{compareAttribute}'=>$compareTo will fix the issue, though it may be a little bit more subtle.
The fact that the documentation doesn't mention this placeholder is actually a good thing until this is fixed, however this placeholder is absolutely necessary.
The text was updated successfully, but these errors were encountered: