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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

GridField and Hierarchy extension


Go to End


958 Views

Avatar
Mo

Community Member, 541 Posts

9 August 2016 at 1:44am

Hi All,

I was just wondering if anyone has managed to implement a GridField that allows you to edit records that use the hierarchy extension?

I think I am almost there, but everytime I add a new record (or edit an existing item) and set the ParentID, the CMS redirects me back to the parent GridField and all the admin JS breaks (requiring a refresh).

The basic call in my getCMSFields is as follows:

$fields->addFieldToTab(
    'Root.Children',
    GridField::create(
        "Children",
        "",
        Category::get()->filter("ParentID", $this->ID),
        new GridFieldConfig_RelationEditor()
    )
);

I have tried various different config classes (and have even written my own), to no effect. I suspect the issue might be that once I change the parent ID, the item no longer exists in the current list, and that is causing this behaviour. But i am not 100% if this is the case and was wondering if anyone has overcome this hurdle?

Many thanks,

Mo