Make the setEmptyString configurable

This commit is contained in:
Thomas B. Nielsen 2014-10-06 17:50:40 +02:00
parent 7bf3cf9a31
commit d1953b195d
2 changed files with 11 additions and 1 deletions

View File

@ -0,0 +1,5 @@
---
name: gridfieldextensions
---
GridFieldAddNewMultiClass:
showEmptyString: false

View File

@ -10,6 +10,9 @@ class GridFieldAddNewMultiClass implements GridField_HTMLProvider, GridField_URL
private static $allowed_actions = array(
'handleAdd'
);
// Should we add an empty string to the add class dropdown?
private static $showEmptyString = true;
private $fragment;
@ -150,7 +153,9 @@ class GridFieldAddNewMultiClass implements GridField_HTMLProvider, GridField_URL
GridFieldExtensions::include_requirements();
$field = new DropdownField(sprintf('%s[ClassName]', __CLASS__), '', $classes);
$field->setEmptyString(_t('GridFieldExtensions.SELECTTYPETOCREATE', '(Select type to create)'));
if (Config::inst()->get('GridFieldAddNewMultiClass', 'showEmptyString')) {
$field->setEmptyString(_t('GridFieldExtensions.SELECTTYPETOCREATE', '(Select type to create)'));
}
$field->addExtraClass('no-change-track');
$data = new ArrayData(array(