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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Data Model Questions /

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

SS3 Versioned Data in Model Admin


Go to End


3 Posts   2016 Views

Avatar
zenmonkey

Community Member, 545 Posts

21 June 2012 at 3:16am

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

Community Member, 8 Posts

24 July 2012 at 5:44pm

Edited: 24/07/2012 5:46pm

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

Community Member, 19 Posts

15 November 2012 at 11:09pm

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

Cheers!