Контекст:
Пусть есть две сущности (правильно отображаемые для Doctrine).
-
Post
со свойствами {$id
(integer, autoinc),$name
(строка),$tags
(коллекцияTag
)} -
Tag
со свойствами {$id
(integer, autoinc),$name
(строка),$posts
(коллекцияPost
)}
Отношения между этими двумя являются Many-To-Many
.
Проблема:
При создании нового Post
я хочу сразу добавить к нему теги.
Если бы я захотел добавить Tags
, который уже был изменен, я бы создал тип поля сущности, без проблем.
Но, что бы я сделал, если бы я хотел добавить полностью новый Tags
тоже? (Проверьте некоторые из уже существующих тегов, введите имя для нового тега, возможно, добавьте еще один новый тег, затем после отправки назначить правильное присвоение Post
сущности)
Create new Post: Name: [__________] Add tags | |[x] alpha |[ ] beta |[x] gamma | |My tag doesnt exist, create new: | |Name: [__________] | |+Add another new tag
Есть ли способ сделать это? Я знаю основы Symfony 2, но понятия не имею, как с этим бороться. Также удивил меня, что я нигде не нашел свой ответ, кажется для меня общей проблемой. Что мне не хватает?