diff --git a/src/TagField.php b/src/TagField.php index 5b74bc5..2a91410 100644 --- a/src/TagField.php +++ b/src/TagField.php @@ -275,7 +275,7 @@ protected function getOptions($onlySelected = false) if ($values) { if (is_array($values)) { - $values = DataList::create($dataClass)->filter($titleField, $values); + $values = $source->filter($titleField, $values); } } if ($onlySelected) { @@ -390,6 +390,9 @@ protected function getOrCreateTag($term) $record = Injector::inst()->create($dataClass); $record->{$titleField} = $term; $record->write(); + if ($source instanceof SS_List) { + $source->add($record); + } return $record; }