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

Adding children to an object when a many-to-many link is established with another


Go to End


1052 Views

Avatar
sdc395

Community Member, 2 Posts

10 July 2015 at 10:10pm

Hi everyone

I have a hierarchy of "template" DataObjects (a Package has Modules, a Module has Features). When I use the CMS to edit a Product (which has a many-to-many relationship with Package) and link a Package to the Product, I want the CMS to merge any missing Modules and Features of the Package into the Product (the non-template objects have their own classes that relate back to Product).

Is there a "right" way of going about this? I've been trying to intercept the call to ManyManyList::add when adding a Package to a Product so I can do the extra processing at that point but this approach doesn't feel right. I also don't know how I'd go about getting the client-side updated with the unexpected server-side changes I'd be making.

Has anyone else got this sort of scheme working?

Thanks In advance
Simon