Closed
Description
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
my form field definition:
use Symfony\Bridge\Propel1\Form\Type\ModelType;
...
$builder
->add(
'TakeByWebType',
ModelType::class,
[
'label' => 'Type',
'required' => true,
'class' => '\Posse\SurveyBundle\Model\Type\TakeByWebType',
'query' => $query,
'property' => 'description',
]
);