Merge pull request #48 from mediabeastnz/added-isMultiple-option

Added option to disable multiple selections.
This commit is contained in:
Christopher Pitt 2015-10-09 11:37:31 +13:00
commit 89767f93d3
2 changed files with 44 additions and 2 deletions

View File

@ -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+

View File

@ -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());