0

I am using js library that allows user to add new values into html select element but I cannot find a way handing that new values from symfony side and dynamically add new option.

As one of the solutions I was trying to use 'choice_loader' options with default ChoiceType field and implementing ChoiceLoaderInterface like in this post but there should be a simpler way.

Khadija
  • 310
  • 1
  • 9

1 Answers1

0

I don't think you can do it in an other way with a ChoiceType but maybe you can create you own custom type :

  • You can create your select element by customize your form rendering or/and default classes set in your custom FormType.
  • You can use a ModelTransformer in order to retrieve your existing values and create new ones
  • You can use a simple TextType in inheritance format the data send by the form with a delimiter and create a ViewTransformer in order to retrieve a collection on the other side
Fabien Salles
  • 1,101
  • 15
  • 24