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.

Data Model Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

DataObjectDecorator and has_many

Go to End

2 Posts   2188 Views


Community Member, 78 Posts

6 August 2010 at 9:42pm

Edited: 06/08/2010 9:43pm


i want to create an "Reminder" extension.
In our project are many custom DataObjects handled inside ModelAdmin.
To some of them i want to add a "Reminder" functionality.

I decided to create a DataObjectDecorator, but i get errors.

Here are the code Snippets:

The Reminder DataObject itself:

class Reminder extends DataObject {

    public static $db = array(
        'Title'     => 'Varchar(256)',
        'Deadline'  => 'SS_Datetime',
        'Message'   => 'HTMLText',
        'Priority'  => 'Enum("low,medium,high","medium")'

    public static $has_one = array(



The Decorator:

class ReminderExtension extends DataObjectDecorator {

	function extraStatics() {
		return array(
			'has_many' => array(
				'Reminders' => 'Reminder'


        public function updateCMSFields(FieldSet $fields) {

            $table = new HasManyDataObjectManager($this->owner, 'Reminders', 'Reminder', array('Title' => 'Title'));
            $fields->addFieldToTab('Root.Content.Reminders', $table);


And inside of some Dataobjects i deine the extension/the decorator

     static $extensions = array(

But when klicking inside ModelAdmin of an Dataobject to edit:

Warning: "array_flip() [function.array-flip]: The argument should be an array" at line 1334 of....../html/sapphire/core/model/DataObject.php

I am working with SS 2.4.1

Any ideas ?


Community Member, 288 Posts

12 August 2010 at 12:05am

This is tricky since the way SS handles has_many. Adding has_many to a class doesn't actually do anything database wise, the system expects a has_one on the other side to know what to do and it's when the has_one is created that the correct stuff shows up in the db.

In short I'm not sure if this is doable in this manner.