Jump to:

7940 Posts in 1543 Topics by 946 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Dataobjectmanager inside Member decorator?

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: 510 Views
  • flipsidenz
    Community Member
    49 Posts

    Dataobjectmanager inside Member decorator? Link to this post

    I have a scenario where I am trying to assign (has_many) subscriptions to a member. Via the CMS, I would like to be able to edit a member in the security tab, and in the popup window have a dataobjectmanager on the "Subscription" tab, which allows me to add subscriptions to the member.

    Catch is, I have a DataObjectDecorator for the Member class. Using the code below, I have it setup so the Dataobjectmanager does appear on the subscription tab, but:

    A) it is poorly formatted and
    B) after I add the first dataobject, the edit member popup errors from there on in:

    [User Error] Uncaught Exception: Object->__call(): the method 'fortemplate' does not exist on 'Member'

    Can anyone help me setup this dataobjectmanager on the edit member popup?


    class MemberDecorator extends DataObjectDecorator {

       function extraStatics() {
          return array (
          'db' => array(
              'PhoneNumber' => 'Varchar(255)',
                'Status' => "Enum('Active,Disabled','Disabled')",
             'defaults' => array(
              'Status' => 'Disabled'
             'has_many' => array( 'Subscription' => 'Subscription' ));
       public function updateCMSFields(FieldSet $fields) {
             new DataObjectManager($this->owner, 'Subscription', 'Subscription')




    class Subscription extends DataObject {
    static $db = array(
          'From' => 'Date',
          'To' => 'Date',
    'Type' => "Enum('Associates, Full')",
    'Amount' => 'Varchar(150)',
          'Status' => "Enum('Unpaid, Paid', 'Unpaid')"
       //Fields to show in the DOM table
    static $summary_fields = array(
       static $has_one = array('Member' => 'Member');
       static $defaults = array ();
       //static $default_sort = "DosageDate DESC";
       public function getCMSFields()
    $fields = parent::getCMSFields();

    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.