Skip to content
Advertisement

Symfony – ChoiceType with multiple and resetViewTransformers returns invalid_message

We have upgraded our project to Symfony 4.4.35 2 months ago and now I noticed a strange behavior. When I use ChoiceType with the following configuration, the form returns error (This value is not valid):

JavaScript

The POST:

JavaScript

Can someone tell me what has changed? I have tried to inspect ChoiceType.php, and find out the problem is here:

JavaScript

The question is: How to create multiselect with variable length and custom values?

Advertisement

Answer

I had to use SymfonyComponentFormExtensionCoreTypeCollectionType with option allow_add.

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement