Skip to content

[Form] Fix choice keys and values for custom field types #7940

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

Closed

Conversation

michaelperrin
Copy link
Contributor

Choices labels are defined as the keys of the array as of Symfony 3 (see symfony/symfony#14050).

I prefered to keep the same parameters for the "Creating your Field Type as a Service" section and call array_flip as I think it is clearer to keep the keys as keys (!) for parameters, especially as the labels could contain some spaces.

@xabbuh
Copy link
Member

xabbuh commented May 23, 2017

Can you also fix the PHP code example setting the container parameter? Currently, it defines two parameters genders.f and genders.m while we need one parameter genders being an array.

Choices labels are defined as the keys of the array as of Symfony 3 (see symfony/symfony#14050).
@michaelperrin michaelperrin force-pushed the fix/custom-form-type branch from 342ad02 to 7cadd32 Compare May 23, 2017 15:50
@michaelperrin
Copy link
Contributor Author

@xabbuh Done!

@xabbuh xabbuh added this to the 2.7 milestone May 24, 2017
@xabbuh
Copy link
Member

xabbuh commented May 26, 2017

Thank you @michaelperrin.

xabbuh added a commit that referenced this pull request May 26, 2017
…(michaelperrin)

This PR was submitted for the 3.2 branch but it was merged into the 2.7 branch instead (closes #7940).

Discussion
----------

[Form] Fix choice keys and values for custom field types

Choices labels are defined as the keys of the array as of Symfony 3 (see symfony/symfony#14050).

I prefered to keep the same parameters for the "Creating your Field Type as a Service" section and call `array_flip` as I think it is clearer to keep the keys as keys (!) for parameters, especially as the labels could contain some spaces.

Commits
-------

74b662b Fix choice keys and values for custom field types
@xabbuh xabbuh closed this May 26, 2017
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.

3 participants