From 2af998d504c19e0000768a2cbedaac0cd1e667b5 Mon Sep 17 00:00:00 2001 From: Ivo Valchev Date: Tue, 16 Feb 2021 10:38:53 +0100 Subject: [PATCH] Don't show old fields in a `set` if they're removed from the definition --- src/Entity/Field/SetField.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Entity/Field/SetField.php b/src/Entity/Field/SetField.php index a6b84438..fdda6b44 100644 --- a/src/Entity/Field/SetField.php +++ b/src/Entity/Field/SetField.php @@ -83,7 +83,10 @@ class SetField extends Field implements FieldInterface, FieldParentInterface, Li { $fieldsFromDefinition = $this->getFieldsFromDefinition(); - return array_merge($fieldsFromDefinition, $this->getDefaultValue(), $this->getValue()); + // Values from the database, but not of fields that are no longer in the definition. + $value = array_intersect_key($this->getValue(), $fieldsFromDefinition); + + return array_merge($fieldsFromDefinition, $this->getDefaultValue(), $value); } private function getFieldsFromDefinition(): array