Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Managing many-to-many join table with Model Admin


Go to End


4 Posts   2497 Views

Avatar
Nick Frandsen

Community Member, 2 Posts

20 January 2011 at 7:44pm

Hey Guys,

I have a many-to-many relationship that creates a corresponding join table in our db.

It would be nice to be able to add records to the join table through the cms using the model admin. I don't think Model Admin natively supports this because when setting managed_models you cant simply input a db table name that doesn't have a corresponding DataObject. It shouldnt be too difficult to extend the model admin to solve this problem, but there's a few different ways it could be done. has anyone else done it in a particularly elegant fashion that they would like to share? :)

Cheers

Avatar
swaiba

Forum Moderator, 1899 Posts

20 January 2011 at 10:42pm

used this one often (had issues with latest ie)...
http://www.silverstripe.org/multiselectfield-module/

haven't tried this one...
http://www.silverstripe.org/asm-multi-select-field-module/

Avatar
apiening

Community Member, 60 Posts

21 January 2011 at 11:02am

Hi Nick,

I have two more:

ItemSetField, nice picker implementation for hasone, hasmany and manymany:
https://github.com/ajshort/silverstripe-itemsetfield

and of course the native implementation for managing ManyMany relations: ManyManyComplexTableField
http://api.silverstripe.org/2.4/forms/fields-relational/ManyManyComplexTableField.html
http://doc.silverstripe.org/sapphire/en/tutorials/5-dataobject-relationship-management#project-module-relation

Cheers

Avatar
Nick Frandsen

Community Member, 2 Posts

21 January 2011 at 11:26am

Edited: 21/01/2011 11:29am

Cheers guys! We have quite a few instances of both the models in involved in the many-to-many so will check out the suggested plugins to help manage them.