SilverStripe

Remove Add button from GridField

Sometimes you need to be able to edit and delete GridField records, but you don't want the big green "Add New Object" button at the top. Here's how you remove it:

$config = GridFieldConfig_RecordEditor::create();
$config->removeComponentsByType($config->getComponentByType('GridFieldAddNewButton'));