Hi Everyone
silverstripe 4.X,
By Default $many_many field with DataObject displays Edit and Unlink in GridMenu.
I have gridField in page with $many_many to other pages, In Grid Action menu it is showing Edit and ARCHIVE
Is there any way I can enable Unlink for the pages as well in gried action menu.
Thanks
private static $many_many = [
'Categories'=>NewsCategory::class // NewsCategory extends Page
];
// public function getCMSFields()
$category_config = GridFieldConfig_RelationEditor::create();
$category = ToggleCompositeField::create(
'CategoriesSection',
$this->fieldLabel('Categories'),
array(
new GridField('Categories','Categories',$this->Categories(),$category_config)
)
);
Hi,
TLDR; just add below after the line: $category_config = GridFieldConfig_RelationEditor::create(); to fix the problem:
$category_config->removeComponentsByType(âSilverStripe\Versioned\GridFieldArchiveActionâ);
example:
$config = GridFieldConfig_RelationEditor::create();
$config->removeComponentsByType('SilverStripe\Versioned\GridFieldArchiveAction');
$delete = $config->getComponentByType(GridFieldDeleteAction::class);
$delete->setRemoveRelation(true);
Short story long (below is my guessing):
At some point (sorry, just donât have time to look where exactly the point is), when SilverStripe injects âGridFieldArchiveActionâ to Gridfield, they might mess up SilverStripe\Forms\GridField\GridFieldArchiveAction with SilverStripe\Versioned\GridFieldArchiveAction
Hope this helps
Cheers
Leo
1 Like
Thanks a lot, that was really helpful
$config = GridFieldConfig_RelationEditor::create();
$config->removeComponentsByType(âSilverStripe\Versioned\GridFieldArchiveActionâ);
$config->addComponent(new GridFieldDeleteAction(true));