You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After merge from 2.7, forms using ModelType stopped working.
The 'choice' option can be null, array or Traversable, but normalizeLegacyChoices function in ChoiceType forces $choices to be an array. In ModelType choices are fetched from the query, so we need 'choices' to be null. In our case temporary workaround is to add 'choices_as_values' => true
public static function normalizeLegacyChoices(array &$choices, $choiceLabels, &$nextKey = 0)
The error I get is:
Catchable Fatal Error: Argument 1 passed to Symfony\Component\Form\Extension\Core\Type\ChoiceType::normalizeLegacyChoices() must be of the type array, null given, called in /private/var/www/posse/vendor/symfony/symfony/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php on line 266 and defined
This PR was merged into the 2.8 branch.
Discussion
----------
[Form] Fix choices defined as Traversable
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #16792
| License | MIT
| Doc PR | -
Commits
-------
021d93a [Form] Fix choices defined as Traversable
After merge from 2.7, forms using ModelType stopped working.
The 'choice' option can be null, array or Traversable, but
normalizeLegacyChoices
function in ChoiceType forces$choices
to be an array. In ModelType choices are fetched from the query, so we need 'choices' to be null. In our case temporary workaround is to add'choices_as_values' => true
public static function normalizeLegacyChoices(array &$choices, $choiceLabels, &$nextKey = 0)
The error I get is:
my form field definition:
The text was updated successfully, but these errors were encountered: