I have a multiple selection:
$builder ->add('availability', ChoiceType::class, [ 'label' => 'Months of availability', 'choices' => [ 'November 2020' => '2011', 'December 2020' => '2012', 'January 2021' => '2101' ], 'multiple' => true ]);
If I submit [‘2010‘,’2011′,’2012′,’2101’], thus including a month that cannot be found under ‘choices’, Symfony discards the full incoming array, and $form->get(‘availability’)->getData() is null. In my case, when editing an existing record, I would like to be able to send previous selected months of availability as well, and that Symfony would simply exclude/filter out the non-matching choices (but to keep the valid choices). Is that possible?
Source: Symfony Questions
Was this helpful?
0 / 0