From 55e03731bf06efff3dc8cfe1877e6b4c09d828f6 Mon Sep 17 00:00:00 2001 From: Joseph Madden Date: Thu, 14 Oct 2021 19:38:53 -0500 Subject: [PATCH] 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 --- src/TagField.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/TagField.php b/src/TagField.php index 86fcf6e..d3595bc 100644 --- a/src/TagField.php +++ b/src/TagField.php @@ -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(); }