Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 994e90c

Browse files
committed
minor #22230 [Form] Avoid forcing to define the choices_as_values option when using choice_loader (stof)
This PR was merged into the 2.8 branch. Discussion ---------- [Form] Avoid forcing to define the choices_as_values option when using choice_loader | Q | A | ------------- | --- | Branch? |2.8 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a When using the choice loader, choices are ignored entirely. Forcing the dev to add the choices_as_values just to avoid the deprecation warning (and then to remove the option again at some point in 3.x due to deprecation) is a bad developer experience. Commits ------- fb4d8de Avoid forcing to define the choices_as_values option when using choice_loader
2 parents a0e654d + fb4d8de commit 994e90c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ public function configureOptions(OptionsResolver $resolver)
357357
};
358358

359359
$choicesAsValuesNormalizer = function (Options $options, $choicesAsValues) use ($that) {
360-
if (true !== $choicesAsValues) {
360+
if (true !== $choicesAsValues && null === $options['choice_loader']) {
361361
@trigger_error(sprintf('The value "false" for the "choices_as_values" option of the "%s" form type (%s) is deprecated since version 2.8 and will not be supported anymore in 3.0. Set this option to "true" and flip the contents of the "choices" option instead.', $that->getName(), __CLASS__), E_USER_DEPRECATED);
362362
}
363363

0 commit comments

Comments
 (0)