Skip to content

[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

Merged
merged 1 commit into from
Feb 18, 2020

Conversation

HeahDude
Copy link
Contributor

Revival of #6393

@HeahDude HeahDude added the Form label Feb 17, 2020
@HeahDude HeahDude added this to the 3.4 milestone Feb 17, 2020
@HeahDude HeahDude requested a review from xabbuh as a code owner February 17, 2020 07:50
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
Copy link
Member

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.

Copy link
Contributor Author

@HeahDude HeahDude Feb 17, 2020

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.

Copy link
Member

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!

Copy link
Contributor Author

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

Copy link
Contributor Author

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

Copy link
Contributor

@OskarStark OskarStark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

@OskarStark
Copy link
Contributor

Thank you Jules.

OskarStark added a commit that referenced this pull request Feb 18, 2020
This PR was squashed before being merged into the 3.4 branch.

Discussion
----------

[Form] minor fixes in ChoiceType options

Revival of #6393

Commits
-------

4ee4102 [Form] minor fixes in ChoiceType options
@OskarStark OskarStark merged commit 4ee4102 into symfony:3.4 Feb 18, 2020
@HeahDude HeahDude deleted the fix-form-options branch February 18, 2020 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants