Avoid forcing to define the choices_as_values option when using choice_loader

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.
This commit is contained in:
Christophe Coevoet 2017-03-31 10:23:48 +02:00
parent a0e654d981
commit fb4d8de5e4

View File

@ -357,7 +357,7 @@ class ChoiceType extends AbstractType
};
$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);
}