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

[SOLVED] Problem Adding DataObjectManager


Reply

3 Posts   704 Views

Avatar
zenmonkey

1 October 2009 at 9:54am (Last edited: 1 October 2009 10:55am), Community Member, 528 Posts

I can't seem to add the DOM to CMS, its working in other page types, It must be a typo I'm not seeing

Here is the DataObject

class AccessCodeUser extend DataObject {
   static $db - array(
                'Name' => 'Text',
                'Email' => 'Text',
                'ProductName' => 'Text'
                );
   
   static $has_one = array(
      'AccessCodePage' => 'AccessCodePage',      
   );
   
   public function getCMSFields_forPopup()
   {
      return new FieldSet (
                      new TextField('Name'),
                      new EmailField('Email'),
                      new TextField('ProductName')
                      );
   }
}

And in the PageType

class AccessCodePage extends Page {
   public static $db = array(
                      'LifestyleText' => 'HTMLVarchar(255)',
                      'AccessCode' => 'Text'
                      );
   
   public static $has_many = array (
                      'ExtraPageImages' => 'ExtraPageImages',
                      'AccessCodeUsers' => 'AccessCodeUser'
   );
   
   function getCMSFields() {
      $f = parent::getCMSFields();
      
      $f->removeFieldFromTab('Root.Content.Main', 'LifestyleText');
      $f->addFieldToTab("Root.Content.AccessCode", new TextField("AccessCode","Access Code"));
      $f->addFieldToTab("Root.Content.AccessCode", new DataObjectManager(
                                                       $this,
                                                       'AccessCodeUsers',
                                                       'AccessCodeUser',
                                                       array('Name' => 'Name','Email'=>'Email','ProductName' => 'ProductName'),
                                                       'getCMSFields_forPopup'
                                                       ));
      
      
      return $f;
      
   }
   
}

Avatar
UncleCheese

1 October 2009 at 10:09am 4085 Posts

What do you mean you "can't?" Errors? What's it doing/not doing?

Avatar
zenmonkey

1 October 2009 at 10:47am (Last edited: 1 October 2009 10:56am), Community Member, 528 Posts

Standard White Screen when Accessing the CMS even in Devmode. Everything is fine until I add the DataObejctManager.

EDIT Found the Typo