[Form] Deprecated choice_attr
as nested arrays mapped by indexes
#36272
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Extracted from #16834, which I'll split in 3 to ease the review/merge process, hopefully in time for 5.1.
This PR deprecates using the
choice_attr
option as array of arrays of attributes per choice index, in favor of a new (more intuitive) support for a global array of attributes for all choices, or already implemented callable usage to define attributes per choice (or index or value).Before:
After:
There has been many issues in the past on the docs and Stack Overflow (ref #symfony/symfony-docs#6443), because the choice indexes are not always known, and with both using a callable to define global attributes, current ways are error prone. In consequence, this will also simplify the documentation of the option.
This PR also have a side effect on a potential new choice_label_attr (branch pending), because its behavior (and doc) should be the same.