Stephen Melrose
Stephen Melrose

Reputation: 4830

How to implement a Symfony form with a many-to-many relationship?

I have three tables forming a many-to-many relationship. They are,

WebUserRole -> WebUserRolePermission <- WebUserPermission

I've just started doing the admin for my WebUserRole object (using the propel:generate-admin), and I want the form for the WebUserRole to list the permissions with a check box next to each.

Now, is there a built in widget/way of doing this properly? Or will it require a bit of manual tinkering? Links to examples/tutorials are very welcome!

Thank you.

Upvotes: 1

Views: 2266

Answers (1)

nortron
nortron

Reputation: 3891

I believe the widget you're looking for is sfWidgetFormPropelChoiceMany and you construct it with a model to pull the list from:

$this->widgetSchema['permissions_list'] => new sfWidgetFormDoctrineChoiceMany(array('model' => 'WebUserPermission'));

If you haven't seen it yet you should really check out the sfGuardPlugin mentioned by prodigitalson, it is a very robust authentication system with built-in custom permission management.

Upvotes: 1

Related Questions