-
-
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
Is this expected behaviour on unsafe attributes validation? #20110
Comments
Please use latest version of Yii 2 to see if this is still a problem. |
Sorry for late reply. |
I can confirm this, although it is an effect of abusing the way the framework works (but still needs to be fixed). Unsafe attributes (not suitable for mass loading, prefixed with
because it doesn't make sense (but it's still possible). The situation you have here is exactly this case although moved to a different place. Since Yii is gathering all the attributes for validation, it treats Quick fix for you is it to move the marking the attributes unsafe to As for fixing it in the framework itself I would change this line to:
but I'm not sure how it would affect the rest of the code (probably it would not), needs some testing. |
Agree. Thanks for the quick fix. |
This is still an error. And the doc never mention it can be done in the rules ;) |
What steps will reproduce the problem?
Define an unsafe attribute with multiple rules in a model.
Prepare the unit test using Codeception.
Run Codeception.
What's expected?
The validation should occur once for each rule on
account_id
.What do you get instead?
Additional info
If all instances of
account_id
in the rules are marked with "!", the expected behavior is produced.The text was updated successfully, but these errors were encountered: