简体   繁体   中英

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.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM