Answer the question
In order to leave comments, you need to log in
How in Symfony2 to make friends a select without multiple with an Entity property that is ManyToMany?
Hello.
There is an entity called Brief, it can belong to several categories, i.e. it has a $categories property annotated with ManyToMany and JoinTable .
However, depending on the role of the user, he can choose either only one category, or several, which means select multiple and simple select.
I tried to do with the entity field type without multiple - it displays select, but does not save, since Entity expects an ArrayCollection (ManyToMany).
How to be? Maybe there are some options?
Answer the question
In order to leave comments, you need to log in
for a limited user, use a field without multiple, and then after submitting the form, but before saving, turn it into an ArrayCollection - create a collection directly in the same field and add your one category to it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question