Extending EntityType to allow extra choices set with AJAX calls

后端 未结 2 729
粉色の甜心
粉色の甜心 2021-01-01 03:08

I try to create a Symfony Custom type extending the core \"entity\" type.

But I want to use it with Select2 version 4.0.0

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-01 04:01

    Problem solved.

    The solution is to recreate the form field with 'choices'=>$selectedChoices in both PRE_SET_DATA and PRE_SUBMIT FormEvents.

    Selected choices can be retrived from the event with $event->getData()

    Have a look on the bundle I created, it implements this method :

    Alsatian/FormBundle - ExtensibleSubscriber

提交回复
热议问题