mirror of
https://github.com/silverstripe/silverstripe-tagfield
synced 2024-10-22 11:05:32 +02:00
Allow use of setHasEmptyDefault() in StringTagField
This commit is contained in:
parent
e205fb4f6d
commit
cbf8050f2a
@ -161,6 +161,11 @@ class StringTagField extends DropdownField
|
||||
$this->setAttribute('multiple', 'multiple');
|
||||
}
|
||||
|
||||
if ($this->getHasEmptyDefault()) {
|
||||
$this->setAttribute('data-allow-clear', true);
|
||||
$this->setAttribute('data-placeholder', $this->getEmptyString() ?: ' ');
|
||||
}
|
||||
|
||||
if ($this->getShouldLazyLoad()) {
|
||||
$this->setAttribute('data-ss-tag-field-suggest-url', $this->getSuggestURL());
|
||||
} else {
|
||||
@ -199,6 +204,14 @@ class StringTagField extends DropdownField
|
||||
|
||||
$values = $this->Value();
|
||||
|
||||
if ($this->getHasEmptyDefault()) {
|
||||
$options->push(ArrayData::create(array(
|
||||
'Value' => '',
|
||||
'Title' => '',
|
||||
'Selected' => empty($values)
|
||||
)));
|
||||
}
|
||||
|
||||
foreach ($source as $value) {
|
||||
$options->push(
|
||||
ArrayData::create(array(
|
||||
|
Loading…
Reference in New Issue
Block a user