From e9fbb037981ee9880a152e21cf78e48b09ed9490 Mon Sep 17 00:00:00 2001 From: Mark Taylor Date: Thu, 7 Jun 2018 14:16:00 +1000 Subject: [PATCH] Enable UseEmptyString --- src/editableformfields/EditableDynamicListField.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/editableformfields/EditableDynamicListField.php b/src/editableformfields/EditableDynamicListField.php index dde0e9b..ff448a8 100644 --- a/src/editableformfields/EditableDynamicListField.php +++ b/src/editableformfields/EditableDynamicListField.php @@ -41,7 +41,7 @@ class EditableDynamicListField extends EditableDropdown ); private static $table_name = 'EditableDynamicListField'; - + private static $singular_name = 'Dynamic List field'; private static $plural_name = 'Dynamic List fields'; @@ -62,14 +62,14 @@ public function getCMSFields() // get a list of data lists to select from $allLists = DataObject::get(DynamicList::class); - + $options = array('Please create a DynamicList!' => '(No DynamicLists available)'); - + if ($allLists) { /* @var $allLists DataObjectSet */ $options = $allLists->map('Title', 'Title'); } - + $fields->addFieldToTab('Root.Main', DropdownField::create('ListTitle', _t('EditableDataListField.DYNAMICLIST_TITLE', 'List Title'), $options)); return $fields; } @@ -79,6 +79,9 @@ public function getFormField() $field = DynamicListField::create($this->Name, $this->Title, $this->ListTitle) ->setFieldHolderTemplate('UserFormsField_holder') ->setTemplate('UserFormsDropdownField'); + if ($this->UseEmptyString) { + $field->setEmptyString(($this->EmptyString) ? $this->EmptyString : ''); + } $this->doUpdateFormField($field); return $field; }