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

SS3 Versioned Data in Model Admin


Reply

3 Posts   1076 Views

Avatar
zenmonkey

21 June 2012 at 3:16am Community Member, 528 Posts

I'm trying to manage a Versioned DataObject in ModelAdmin as soon as I make the Object versioned I get the following error in the Model Admin
[Warning] array_flip() expects parameter 1 to be array, null given

Any Ideas?

Avatar
nikrolls

24 July 2012 at 5:44pm (Last edited: 24 July 2012 5:46pm), Community Member, 8 Posts

Same issue here. I narrowed it down to the fact that my DataObject didn't have a has_one relationship (the offending line is looking for has_one IDs):

[Warning] array_flip() expects parameter 1 to be array, null given
GET /admin/tests/Test/EditForm/field/Test/item/2/edit

Line 1374 in C:\wamp\www\framework\model\DataObject.php

To avoid the bug, the class being extended by Versioned must have a has_one relationship to either itself or another DataObject.

This code works:

class Test extends DataObject {

static $has_one = array(
'Image' => 'Image'
);
static $extensions = array(
'Versioned'
);

}

Whereas this code doesn't:

class Test extends DataObject {

static $extensions = array(
'Versioned'
);

}

Same results when using the usual Object::add_extension method.

Could anyone shed some light on why a has_one relationship is necessary?

Avatar
t|m

15 November 2012 at 11:09pm Community Member, 19 Posts

Not sure if you are still having this issue, but take a look at
https://github.com/icecaster/silverstripe-versioned-gridfield

Cheers!