From 3a1d59da4044e11d888c13fc9cc0eb1dc2e50870 Mon Sep 17 00:00:00 2001 From: 3Dgoo Date: Tue, 23 Jan 2018 08:49:23 +1030 Subject: [PATCH] Remove add button from ModelAdmin Remove DataChangeRecord GridFieldAddNewButton from DataChangeAdmin. --- code/controllers/DataChangeAdmin.php | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/code/controllers/DataChangeAdmin.php b/code/controllers/DataChangeAdmin.php index 64d2902..13dc2aa 100644 --- a/code/controllers/DataChangeAdmin.php +++ b/code/controllers/DataChangeAdmin.php @@ -4,12 +4,22 @@ * @author marcus@symbiote.com.au * @license BSD License http://silverstripe.org/bsd-license/ */ -class DataChangeAdmin extends ModelAdmin { - public static $managed_models = array( - 'DataChangeRecord', - ); +class DataChangeAdmin extends ModelAdmin +{ + public static $managed_models = array( + 'DataChangeRecord', + ); - public static $url_segment = 'datachanges'; - public static $menu_title = 'Data Changes'; + public static $url_segment = 'datachanges'; + public static $menu_title = 'Data Changes'; + public function getEditForm($id = null, $fields = null) + { + $form = parent::getEditForm($id); + $gridField = $form->Fields()->fieldByName($this->modelClass); + $gridFieldConfig = $gridField->getConfig(); + $gridFieldConfig->removeComponentsByType('GridFieldAddNewButton'); + + return $form; + } }