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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

DOM + ModelAdmin, how?


Reply


4 Posts   847 Views

Avatar
danzzz

Community Member, 175 Posts

3 June 2010 at 11:55pm

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

Avatar
UncleCheese

Forum Moderator, 4094 Posts

4 June 2010 at 1:43am

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

Avatar
danzzz

Community Member, 175 Posts

4 June 2010 at 3:22am

Edited: 04/06/2010 3:23am

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

Avatar
UncleCheese

Forum Moderator, 4094 Posts

4 June 2010 at 4:49am

getCMSFields() needs to return a FieldSet.