Jump to:

3429 Posts in 1057 Topics by 734 members

Data Model Questions

SilverStripe Forums » Data Model Questions » want many_many relation maintained on both ends

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

Page: 1
Go to End
Author Topic: 671 Views
  • mtz
    Avatar
    Community Member
    17 Posts

    want many_many relation maintained on both ends Link to this post

    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

    671 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.