I have a form and i need to pass it an array. This array is the result of a query from my repository.

I need to build a drop down menu (with a ChoiceType::class, [ 'choices' => $array['code']...

Q1: how do you pass the array (to the form from the controller)?

Q2: how do you retrieve the 'code' field and use it in the choices of my form?

Q3: do you have an example for this ?

Tried different things but nothing is working...need some help. Thank you.

1

There are 1 best solutions below

0
SGuirous On

enter image description herei have found myslef the solution. The Symfony doc is not really helpfull when creating a dynamic customised choice menu (drop down list). I had to use the $options and to dig dip to find the solution. I am happy because the choices are dynamic and they are linked to the Library that is selected when connecting to the site.enter image description here