-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] Choice types with choice_list option breaks on 2.7 #14382
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
Comments
`@deprecated since version 2.7, to be removed in 3.0.
change the extended class |
@HeahDude Thanks for this indication but deprecated does not mean BC break. Upgrade from |
BTW, using |
This PR was merged into the 2.7 branch. Discussion ---------- [2.7][Form] Fixed ChoiceType with legacy ChoiceList | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #14382 | License | MIT | Doc PR | The "Backwards compatibility" condition doesn't grap (e.g. when passing a `SimpleChoiceList` as `choice_list` on `ChoiceType`), as the default value for the `ChoiceType` option `preferred_choices` is `array()` instead of `null`. So I changed the condition from `null === $preferredChoices` to `empty($preferredChoices)`. Then there was an issue with accessing `attr` in `form_div_layout.html.twig`, since the deprecated `Symfony\Component\Form\Extension\Core\View\ChoiceView` doesn't provide an `attr` attribute. Since the docblocks of `Symfony\Component\Form\ChoiceList\View\ChoiceListView` state `$choices` and `$preferredChoices` to be instances of `Symfony\Component\Form\ChoiceList\View\ChoiceView` instead of `Symfony\Component\Form\Extension\Core\View\ChoiceView` I fixed the template issue by mapping the deprecated `ChoiceView` objects to the new one with an empty `attr`. @webmozart Could you have a look at it, please? Without this PR the following example would render numeric values as labels: ```php $formBuilder->add('choices', 'choice', array( 'choice_list' => new SimpleChoiceList(array( 'creditcard' => 'Credit card payment', 'cash' => 'Cash payment' )) )); ``` Commits ------- a98e484 [Form] Fix ChoiceType with legacy ChoiceList
Form choice type with
choice_list
option seems to be broken on rendering since Symfony 2.7.See the concerned ticket: sonata-project/SonataAdminBundle#2916
And the concerned type: https://github.com/sonata-project/SonataAdminBundle/blob/master/Form/Type/ModelType.php#L103-L115
Can you confirm?
The text was updated successfully, but these errors were encountered: