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.

Customising the CMS /

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

Show and Edit producing errors with editor pop-up (2.4.0)

Go to End

2 Posts   1791 Views


Community Member, 21 Posts

28 May 2010 at 7:33am

Following the ComplexTableField example in Chapter 5 of the SilverStripe book, I've added a news item section for my home page with the following code:


class NewsItem extends DataObject {
static $db = array(
'Headline' => 'Varchar',
'Text' => 'Text',
'StartDate' => 'Date',
'EndDate' => 'Date',
'Link' => 'Varchar'

function getCMSFields() {
$fields = new FieldSet(
new TextField('Headline', 'Headline'),
new TextareaField('Text', 'Blurb'),
new TextField('Link', 'Link'),
new DateField('StartDate', 'Start Date'),
new DateField('EndDate', 'End Date')
return $fields;


class HomePage extends Page {
static $db = array(

static $has_many = array(
'HomePageNews' => 'NewsItem'

function getCMSFields() {
$fields = parent::getCMSFields();
$newsTable = new ComplexTableField($this, 'HomePageNews', 'NewsItem', array('Headline'=>'Headline', 'StartDate'=>'StartDate', 'EndDate'=>'EndDate'));
$fields -> addFieldToTab('Root.Content.NewsItems', $newsTable);
return $fields;
class HomePage_Controller extends Page_Controller {

For the most part things work...I have a lovely new "News Items" tab in the CMS, when I select add I get a pop-up with all of the correct fields, and the news items are saved and deleted from the database as expected.

However, the show and edit buttons produce a "500 - Internal server error" and the SilverStripe log shows:

[27-May-2010 02:49:29] Warning at \sapphire\core\model\DataObject.php line 1328: array_flip() [<a href='function.array-flip'>function.array-flip</a>]: The argument should be an array (http://www.devtechsys.mirror/admin/EditForm/field/HomePageNews/item/1/show?ajax=1)


Thanks so much.



Community Member, 1 Post

10 July 2010 at 1:19am

I've stumbled here trying to debug the same error.

Maybe it will be helpful for somebody in the future. I think you're missing the second part of the relation - at least that was my case.

Adding in NewsItem.php:

static $has_one = array(
   "HomePage" => "HomePage"

should do the trick.