Jump to:

7939 Posts in 1472 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » DOM + ModelAdmin, how?

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: 791 Views
  • danzzz
    Avatar
    Community Member
    175 Posts

    DOM + ModelAdmin, how? Link to this post

    hi

    can anybody give me some hints or some lines of code where I can see how to use ModelAdmin with DOM?

    I have this Object:

    class Network extends DataObject {
       
       static $singular_name = "Network";
       static $plural_name = "Networks";
       
       static $db = array(
          'Name'   =>   'Varchar',
          'Class'   =>    'Varchar',
       );
       
       static $searchable_fields = array(
          'Name'
       );
       
       static $summary_fields = array(
          'Name',
          'Class'
       );
       
       static $has_many = array(
          'Accounts' => 'Account'
       );
    }

    I use ModelAdmin like this:

    class MyAdmin extends ModelAdmin {
       
       public static $managed_models = array(
          'Accout',
          Network'
       );
       
       static $url_segment = 'Affiliatenetzwerke_und_Accounts';
       static $menu_title = 'Affiliatenetzwerke & Accounts verwalten';

    But now, how or where to implement the DOM, for example that I can add items over DOM interface?

    daniel

  • UncleCheese
    Avatar
    4085 Posts

    Re: DOM + ModelAdmin, how? Link to this post

    You don't have a getCMSFields() function defined in your Network object. You need to define one and put the DOM in there.

  • danzzz
    Avatar
    Community Member
    175 Posts

    Re: DOM + ModelAdmin, how? Link to this post

    hi UC,

    i tried this but with no success, I had this in my network object, must something wrong ... because returns:

    Error: "Uncaught Exception: Object->__call(): the method 'datafields' does not exist on 'DataObjectManager'" at line 724 of /var/www/xxx/sapphire/core/Object.php

    DOM

    public function getCMSFields()
       {
          //$f = parent::getCMSFields();
          $f = new DataObjectManager(
             $this,
             'Accounts',
             'Account',
             array(
                'Name' => 'Name',
                'Class'=>'Class'),
             'getCMSFields_forPopup'
          );
          return $f;
       }

    what's wrong here?

    daniel

  • UncleCheese
    Avatar
    4085 Posts

    Re: DOM + ModelAdmin, how? Link to this post

    getCMSFields() needs to return a FieldSet.

    791 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.