Skip to content

Commit

Permalink
Avoid forcing to define the choices_as_values option when using choic…
Browse files Browse the repository at this point in the history
…e_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.
  • Loading branch information
stof committed Mar 31, 2017
1 parent a0e654d commit fb4d8de
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

3 comments on commit fb4d8de

@andreyserdjuk
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It causes cyclic dependency problem in projects when 'choice_loader' closure makes internal call of offsetGet('choices') like sonata-project does.
Now we cannot use $options['options'] inside choices_loader closure.
I think it's more critical than deprecation message (however I also hate it).

@Nek-
Copy link
Contributor

@Nek- Nek- commented on fb4d8de Apr 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andreyserdjuk this deserve an issue !

@andreyserdjuk
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created, #22354.

Please sign in to comment.