Skip to content
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

[Form] Incorrect description for choice_attr option of ChoiceType field #6443

Closed
mvar opened this issue Apr 7, 2016 · 2 comments
Closed

Comments

@mvar
Copy link
Contributor

mvar commented Apr 7, 2016

Current choice_attr description:

Use this to add additional HTML attributes to each choice. This can be an array of attributes (if they are the same for each choice), a callable or a property path (just like choice_label).

Actually it's not possible to set attributes for all choices at once. You need to redefine attributes for each choice separately:

'choice_attr' => [
    'Choice A' => ['class' => 'foo'],
    'Choice B' => ['class' => 'foo'],
    ...
    'Choice Z' => ['class' => 'foo'],
],

Please correct me if I'm wrong.

@HeahDude
Copy link
Contributor

HeahDude commented Apr 7, 2016

Hi @mvar, actually you're right about that. But you can do:

'choice_attr' => function () { return array('class' => 'foo'); },

I've already open an issue symfony/symfony#18318 and a PR to change that.

See also #6393.

I think we can close here. Thank you.

@mvar
Copy link
Contributor Author

mvar commented Apr 7, 2016

@HeahDude thanks for comment. I'm closing this issue as the problem is known :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants