Jump to:

7935 Posts in 1536 Topics by 943 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Multiple DataObject instances in Page

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 404 Views
  • ROlckers
    Community Member
    8 Posts

    Multiple DataObject instances in Page Link to this post

    This topic should probably exist in the General category so please move this if it is not relevant to the DataObjectManager.

    I have a DataObject class called MyDataModel. I also have a page called MyPage which has a 'has_many' relationship with MyDataModel. The MyDataModel has a 'has_one' relationship with MyPage.

    I use the DOM inside MyPage to manage MyDataModel's data.

    My question is this: could I have multiple instances of MyDataModel inside the MyPage class? MyModel1's tab's data should contain only the data as loaded through MyModel1's tab. The same goes for MyModel2's tab etc.. Hope this makes sense.

    My gut tells me this is not possible by doing it the way I describe below as when I performed a dev/build with the additional 'instances' to MyDataModel, nothing happened to the table structure.

    class MyPage extends Page {

       static $has_many = array (
          'MyDataModel1' => 'MyDataModel',
          'MyDataModel2' => 'MyDataModel',
          'MyDataModel3' => 'MyDataModel',
          'MyDataModel4' => 'MyDataModel'

       public function getCMSFields() {
          $fields = parent::getCMSFields();
          $fields->addFieldToTab("Root.Content.MyModel1", new DataObjectManager(
          $fields->addFieldToTab("Root.Content.MyModel2", new DataObjectManager(
          //... etc...
          return $fields;


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.