From 024e648e5a807cc09f702d818ef1a1fcfffe035d Mon Sep 17 00:00:00 2001 From: Simon Gow Date: Thu, 13 Sep 2018 11:18:55 +1200 Subject: [PATCH] Added getSource() function to populate source inline with the api. Source isn't populated to the parent because it's transformed directly to an array. Instead we're lazy loading the source when it's requested. --- src/TagField.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/TagField.php b/src/TagField.php index 3968c3f..986ed4e 100644 --- a/src/TagField.php +++ b/src/TagField.php @@ -312,6 +312,21 @@ class TagField extends DropdownField return parent::setValue(array_filter($value)); } + /** + * Gets the source array if required + * + * Note: this is expensive for a SS_List + * + * @return array + */ + public function getSource() + { + if (is_null($this->source)) { + $this->setSource($this->getSourceList()); + } + return $this->source; + } + /** * {@inheritdoc} */