EntityType input in Symfony with select tag : any way NOT to force the items sequence order?

Viewed 39

I have a symfony EntityType form input, with "multiple" => true. In the example above, the form should collect a list of topics from an existing list in the database. When the user clicks on the input, a dropdown list appears and the user can append/delete items from its selection. The submitted and stored sequence of this list is not in the order in which the user has selected the topics, but rather in the order they have been selected upstream in the database when generating the form. However, it is of importance to me to store the selected topics in the order they were selected by the user (the logic is that the topics relevancy will be of decreasing order).

It there a way to achieve this ?

$builder
->add('topics', EntityType::class, [
    'class'=> Topic::class,
    'choice_label'=>'name',
    'multiple' => true,
    'label'=>'Topic*'])

Layout here.

0 Answers
Related