-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[Form] minor fixes in ChoiceType options #13156
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
reference/forms/types/choice.rst
Outdated
return strtoupper($category->getName()); | ||
// a property path can by used to define the options below | ||
'choice_value' => 'name', | ||
// the empty value can be passed if there is a placeholder |
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 don't understand this comment either:
the empty value can be passed if there is a placeholder
We're describing the choice_label
option ... but we talk about "empty value" and "placeholder". I don't see the relation between all 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.
When a placeholder is set among the choice list it is the empty value (null
as a choice and empty string as value). When the placeholder is not explicitly defined but the field is not required the component adds it as first choice so we can select no choices (opposite of required).
So all callbacks should handle this case, I should better explain that in a dedicated caution I guess.
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 ... maybe a super short comment before the callback that accepts nullable types mentioning that you need that in case you use placeholders ...
... and then maybe a caution message with some more details like you explained in this comment. Thanks!
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've pushed a caution
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.
For the record symfony/symfony#17787
f6a4397
to
5b39460
Compare
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.
👍🏻
41ac9c2
to
4ee4102
Compare
Thank you Jules. |
Revival of #6393