diff --git a/modules/backend/formwidgets/TagList.php b/modules/backend/formwidgets/TagList.php index 9773cb3d7..d718e0b3b 100644 --- a/modules/backend/formwidgets/TagList.php +++ b/modules/backend/formwidgets/TagList.php @@ -110,15 +110,17 @@ public function prepareVars() */ public function getSaveValue($value) { - if (is_array($value)) { - $value = array_filter($value); + if (!is_array($value)) { + $value = [$value]; } + $value = array_filter($value); + if ($this->mode === static::MODE_RELATION) { return $this->hydrateRelationSaveValue($value); } - if (is_array($value) && $this->mode === static::MODE_STRING) { + if ($this->mode === static::MODE_STRING) { return implode($this->getSeparatorCharacter(), $value); } @@ -129,12 +131,8 @@ public function getSaveValue($value) * Returns an array suitable for saving against a relation (array of keys). * This method also creates non-existent tags. */ - protected function hydrateRelationSaveValue($names): ?array + protected function hydrateRelationSaveValue(array $names): ?array { - if (!is_array($names)) { - $names = [$names]; - } - $relation = $this->getRelationObject(); $relationModel = $this->getRelationModel(); diff --git a/modules/backend/formwidgets/taglist/partials/_taglist.php b/modules/backend/formwidgets/taglist/partials/_taglist.php index d9d0991ae..a4170908e 100644 --- a/modules/backend/formwidgets/taglist/partials/_taglist.php +++ b/modules/backend/formwidgets/taglist/partials/_taglist.php @@ -29,7 +29,7 @@