FIX Use existing source datalist if available before creating a new one

Fix for #171 - Issue when utilizing multiple of same parent class

Co-authored-by: Joe Madden <joe.madden@moosylvania.com>
This commit is contained in:
Joseph Madden 2021-10-14 19:38:53 -05:00 committed by GitHub
parent 43ccb16def
commit 55e03731bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -275,8 +275,12 @@ class TagField extends MultiSelectField
// Convert an array of values into a datalist of options
if (!$values instanceof SS_List) {
if (is_array($values) && !empty($values)) {
$values = DataList::create($dataClass)
->filter($this->getTitleField(), $values);
if (is_a($source, DataList::class)) {
$values = $source->filter($this->getTitleField(), $values);
} else {
$values = DataList::create($dataClass)
->filter($this->getTitleField(), $values);
}
} else {
$values = ArrayList::create();
}