GridField Unlink Action for Page

<%- if @topic_view.topic.tags.present? %>
<%= t 'js.tagging.tags' %>: <%- @topic_view.topic.tags.each do |t| %> <%= t %> <%- end %>
<% end %>

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.


private static $many_many = [
'Categories'=>NewsCategory::class // NewsCategory extends Page

// public function getCMSFields()

$category_config = GridFieldConfig_RelationEditor::create();
$category = ToggleCompositeField::create(
        new GridField('Categories','Categories',$this->Categories(),$category_config)



TLDR; just add below after the line: $category_config = GridFieldConfig_RelationEditor::create(); to fix the problem:



$config =   GridFieldConfig_RelationEditor::create();
$delete = $config->getComponentByType(GridFieldDeleteAction::class);

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 :confused:

Hope this helps


1 Like

Thanks a lot, that was really helpful

$config = GridFieldConfig_RelationEditor::create();
$config->addComponent(new GridFieldDeleteAction(true));