Skip to content

Commit

Permalink
Merge pull request #21 from tardinha/master
Browse files Browse the repository at this point in the history
Enable UseEmptyString in EditableDynamicListField
  • Loading branch information
stephenmcm authored Jun 14, 2018
2 parents e213abf + e9fbb03 commit 0b5cb7b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/editableformfields/EditableDynamicListField.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down

0 comments on commit 0b5cb7b

Please sign in to comment.