7911 Posts in 1354 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » Dataobjectmanager inside Member decorator?
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 300 Views |
-
Dataobjectmanager inside Member decorator?

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?
MemberDecorator.php:
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) {
$fields->addFieldToTab('Root.Subscription',
new DataObjectManager($this->owner, 'Subscription', 'Subscription')
);
}}
Subscription.php:
<?php
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(
'Member',
'Type',
'Status'
);
static $has_one = array('Member' => 'Member');
static $defaults = array ();
//static $default_sort = "DosageDate DESC";
public function getCMSFields()
{
$fields = parent::getCMSFields();return $fields;
}
}
| 300 Views | ||
|
Page:
1
|
Go to Top |

