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

Delete blocks #100

Open
ec8or opened this issue Aug 4, 2016 · 3 comments
Open

Delete blocks #100

ec8or opened this issue Aug 4, 2016 · 3 comments

Comments

@ec8or
Copy link

ec8or commented Aug 4, 2016

It doesn't seem to be possible to delete blocks, even from the Block Admin. Should this be added to the config at least?

@balazsbohonyi
Copy link

I stumbled upon this issue in the middle of a project after I created a couple of custom blocks :(

I spent 2 hours figuring out what happens, and found a solution.
There's a configuration class created for managing the blocks in a GridField here: /blocks/code/forms/GridfieldConfig_BlockManager.php

The 3rd parameter of the constructor is $canDelete = true, but when setting the GridField config in the getEditForm() method the constructor for GridfieldConfig_BlockManager is called with false for that argument:

$blockGridField->setConfig(GridFieldConfig_BlockManager::create(true, true, false));

Change it to $blockGridField->setConfig(GridFieldConfig_BlockManager::create(true, true, true)); and it will work.

@balazsbohonyi
Copy link

I also tried to do this by using the Extension API but it's not working since the getEditForm() is missing the following line before the return $form statement:

$this->extend('updateEditForm', $form);

If that line would be there we shouldn't tamper with the core blocks source code - but I'm afraid there's no other way to make this work until it's not fixed.

@balazsbohonyi
Copy link

Forgot to mention where exactly fix this. It's in the getEditForm() method of the BlockAdmin.php class

so change this:

$blockGridField->setConfig(GridFieldConfig_BlockManager::create(true, true, false));

to this:

$blockGridField->setConfig(GridFieldConfig_BlockManager::create(true, true, true));

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