Matt Welander
Matt Welander

Reputation: 8548

symfony2 forms and many-to-many relations

I thought I'd see if anyone could point me in the right direction here - I have a users table and a contents table, and I want to keep track of what user is authorized to edit what content. Thinking in a relational database way, a many-to-many relation table is the solution, adding rows of user_id & content_id for each authorization.

Many users can be authorized to edit a content piece, and a user is also of course able to have access to more than one content piece.

Now, the biggest issue I see (being a Symfony2 novice) is the admin form where an admin must be able to set these permissions, preferrably with a list of contents and checkboxes next to them, and have the form processor take care of the adding/deleting rows to that relationsl table.

Is the collection form field the right way to go here?

Any help is much appreciated.

Upvotes: 0

Views: 337

Answers (1)

fdomig
fdomig

Reputation: 4457

I think the Doctrine2 documentation on Many-to-Many relations already gives you an answer on that question how to map the data.

The form issue is already explained in another SO question.

Upvotes: 1

Related Questions