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.

Data Model Questions /

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

want many_many relation maintained on both ends


Go to End


1369 Views

Avatar
mtz

Community Member, 17 Posts

10 August 2010 at 1:36am

Hello,

i need an many_many relation between all Pages that is maintained on both ends

for now my code looks like this:

class Page extends SiteTree {

static $many_many = array(
'Pages' => 'Page'
);

$pagesList = DataObject::get('Page');
$fields->addFieldToTab('Root.Content.Relations', new CheckboxSetField('Pages', '', $pagesList));

....

but i want also the Checkboxes 'checked' that are related.

So I need a way to ask about the PageID that is related to the ChildID to get both ends of the Relation. Also for the Controller-Class

Cheers,
Mat