mirror of
https://github.com/silverstripe/silverstripe-tagfield
synced 2024-10-22 11:05:32 +02:00
Merge pull request #48 from mediabeastnz/added-isMultiple-option
Added option to disable multiple selections.
This commit is contained in:
commit
89767f93d3
@ -78,6 +78,24 @@ class StringTagField extends DropdownField {
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getIsMultiple() {
|
||||
return $this->isMultiple;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $isMultiple
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function setIsMultiple($isMultiple) {
|
||||
$this->isMultiple = $isMultiple;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|DataObject
|
||||
*/
|
||||
@ -120,6 +138,10 @@ class StringTagField extends DropdownField {
|
||||
|
||||
$this->setAttribute('multiple', 'multiple');
|
||||
|
||||
if ($this->getIsMultiple()) {
|
||||
$this->setAttribute('multiple', 'multiple');
|
||||
}
|
||||
|
||||
if($this->getShouldLazyLoad()) {
|
||||
$this->setAttribute('data-ss-tag-field-suggest-url', $this->getSuggestURL());
|
||||
} else {
|
||||
@ -282,7 +304,7 @@ class StringTagField extends DropdownField {
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DropdownField assumes value will be a scalar so we must
|
||||
* override validate. This only applies to Silverstripe 3.2+
|
||||
|
@ -80,6 +80,24 @@ class TagField extends DropdownField {
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getIsMultiple() {
|
||||
return $this->isMultiple;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $isMultiple
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function setIsMultiple($isMultiple) {
|
||||
$this->isMultiple = $isMultiple;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
@ -130,7 +148,9 @@ class TagField extends DropdownField {
|
||||
|
||||
$this->addExtraClass('ss-tag-field');
|
||||
|
||||
$this->setAttribute('multiple', 'multiple');
|
||||
if ($this->getIsMultiple()) {
|
||||
$this->setAttribute('multiple', 'multiple');
|
||||
}
|
||||
|
||||
if($this->shouldLazyLoad) {
|
||||
$this->setAttribute('data-ss-tag-field-suggest-url', $this->getSuggestURL());
|
||||
|
Loading…
Reference in New Issue
Block a user