-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Using only arrays in rules instead comma-separated string #1184
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
Conversation
framework/yii/base/Model.php
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'username' is fine in this case. Should also fix Gii model generator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes single attribute may be as string, but I think it is not necessary to teach programmers to poor :)
I would even removed the conversion to the array for consistency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remove conversion to array and add type hinting into Validator::createValidator, please tell me your opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imo it should be possible to specify one attribute without brackets. I see no sense in having to add [] each time when one attribute rule is specified. Nearly 3/4 of the rules I created today(created a bunch of new models ;-) ) where only for one attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I agree. But I propose move conversion in Model::createValidators
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed earlier, for single attribute, we prefer to use a string rather than an array. Could you please fix this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
|
I'm for taking this change. With 5.4 array syntax it looks much better than strings. |
Using only arrays in rules instead comma-separated string
|
Thank you very much! |
I think the short form of array is not difficult to write than a comma separated string. But we gain a little bit in performance when creating each model instance.
vs