Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement many-to-many with extra fields in symfony2? [duplicate]

I have "customers", "products" and "versions" tables.Each customer, can have more than one product, and each product has more than one version. I have created many-to-many relation "customers_products" and everything works perfect.

Also I have created one-to-many relation between "products" and "versions".

QUESTION: How to add an extra column (version_id) in "customers_products" table so I can build form where user can choose products and version to create new customer.

like image 971
user3722402 Avatar asked Feb 22 '16 11:02

user3722402


1 Answers

Once an association has data, it's no more an association.

You have to implement two ManyToOne instead of a ManyToMany.

See this great answer on this question for a full example.

You can get a lot of other examples by googling the title of your question.

like image 106
chalasr Avatar answered Oct 14 '22 04:10

chalasr