Skip to content

Commit

Permalink
minor #22230 [Form] Avoid forcing to define the choices_as_values opt…
Browse files Browse the repository at this point in the history
…ion 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
  • Loading branch information
fabpot committed Mar 31, 2017
2 parents a0e654d + fb4d8de commit 994e90c
Showing 1 changed file with 1 addition and 1 deletion.
Expand Up @@ -357,7 +357,7 @@ public function configureOptions(OptionsResolver $resolver)
};

$choicesAsValuesNormalizer = function (Options $options, $choicesAsValues) use ($that) {
if (true !== $choicesAsValues) {
if (true !== $choicesAsValues && null === $options['choice_loader']) {
@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);
}

Expand Down

0 comments on commit 994e90c

Please sign in to comment.