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, Ed, biapar, Willr, Ingo, swaiba

Dataobjectmanager inside Member decorator?

Go to End



Community Member, 49 Posts

22 September 2011 at 9:19pm

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;