Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot add new DataObjects that extend SiteTree when using Blocks #108

Open
warslett opened this issue Dec 14, 2016 · 1 comment
Open

Cannot add new DataObjects that extend SiteTree when using Blocks #108

warslett opened this issue Dec 14, 2016 · 1 comment

Comments

@warslett
Copy link

We have a custom data object that extends SiteTree, we are also using the Blocks extension. This results in us being unable to add new instances of our custom data object under our own ModelAdmin because you cannot use GridFieldOrderableRows with an unsaved many to many collection as described in this open issue with gridfieldextension symbiote/silverstripe-gridfieldextensions#113. The issue does not effect new objects that are created via the Pages admin because in Pages admin, a new object is saved as a draft before the form is loaded but this is not the case if you use your own admin class. We get the following error in our logs:

[14-Dec-2016 14:07:34] Warning at gridfieldextensions/code/GridFieldOrderableRows.php line 146: Argument 1 passed to GridFieldOrderableRows::getSortTable() must be an instance of DataList, instance of UnsavedRelationList given, called in /var/www/html/gridfieldextensions/code/GridFieldOrderableRows.php on line 250 and defined (http://amadeus.dev:32821/admin/public-courses/PublicCourseOutline/EditForm/field/PublicCourseOutline/item/new)

IMO the blocks tab should not be loaded at all until the data object has been saved. We get around the issue by adding the following to our data object's getCMSFields:

if (!$this->isInDB()) {
        $fields->removeFieldFromTab("Root", "Blocks");
}

However IMO the SiteTree extension should be checking this itself to properly address the issue. Will open a PR if I get a chance.

@sheadawson
Copy link
Owner

Hey yeap I see, happy to merge PR if you can send one through :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants