I'm losing a lot of time on a (maybe) basic feature that everyone needs in his project.
The fact is that I'm stuck with form builder (a real daemon in this framework, I don't understand why it's so hard to use).
I got three entities :
Recette
Ingredient
RecettesIngredients
Both Recette and Ingredient do an One-To-Many with RecettesIngredients. It's a many-to-many with extra fields.
I've done a form builder RecetteType that does :
->add('recettesIngredients', CollectionType::class, [
'entry_type' => RecettesIngredientsType::class,
'allow_add' => true,
'allow_delete' => true,
'label' => 'XXX'
])
I've done a form builder (he works fine) RecettesIngredientsType that does :
->add('ingredients', EntityType::class, [
// looks for choices from this entity
'class' => Ingredient::class,
'choice_label' => 'nom',
// used to render a select box, check boxes or radios
'multiple' => true,
'expanded' => true
])
When I try to render it:
{{ form_row(form.recettesIngredients) }}
If I don't give an object to my form builder : I just got nothing to display but a blank page without error.
If I give an object to my form builder : I have an error:
"Unable to transform value for property path "ingredients": Expected a Doctrine\Common\Collections\Collection object."
If I remove the "multiple" option, I got a list of ingredients but without checkboxes to select them.
My question is simple :
How can I display a form in a Many-To-Many with extra field relation context properly?

