Jump to:

3430 Posts in 1057 Topics by 734 members

Data Model Questions

SilverStripe Forums » Data Model Questions » SS3 Versioned Data in Model Admin

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

Page: 1
Go to End
Author Topic: 1018 Views
  • zenmonkey
    Avatar
    Community Member
    527 Posts

    SS3 Versioned Data in Model Admin Link to this post

    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?

  • nikrolls
    Avatar
    Community Member
    8 Posts

    Re: SS3 Versioned Data in Model Admin Link to this post

    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?

  • t|m
    Avatar
    Community Member
    19 Posts

    Re: SS3 Versioned Data in Model Admin Link to this post

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

    Cheers!

    1018 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.