diff --git a/src/Plugin/UiPatterns/Source/FieldPropertySource.php b/src/Plugin/UiPatterns/Source/FieldPropertySource.php index d68a9227bba7a659db02d2885537bb3c358ca794..fa5e9eb93e0af438325cf199bd9776f0da590132 100644 --- a/src/Plugin/UiPatterns/Source/FieldPropertySource.php +++ b/src/Plugin/UiPatterns/Source/FieldPropertySource.php @@ -36,7 +36,11 @@ class FieldPropertySource extends FieldValueSourceBase { return NULL; } $property_value = $this->extractPropertyValue($field_item_at_delta, $property, $lang_code); - $prop_typ_types = (isset($this->propDefinition['type']) && is_array($this->propDefinition['type'])) ? $this->propDefinition['type'] : []; + $prop_typ_types = []; + if (isset($this->propDefinition['type'])) { + // Type can be an array of types or a single type. + $prop_typ_types = is_array($this->propDefinition['type']) ? $this->propDefinition['type'] : [$this->propDefinition['type']]; + } return $this->transTypeProp($property_value, $prop_typ_types); } @@ -56,8 +60,8 @@ class FieldPropertySource extends FieldValueSourceBase { private function transTypeProp(mixed $value, array $prop_types): mixed { foreach ($prop_types as $prop_type) { $converted = match ($prop_type) { - 'decimal', 'integer', 'duration' => is_int($value) ? $value : (int) $value, - 'float' => is_float($value) ? $value : (float) $value, + 'integer' => is_int($value) ? $value : (int) $value, + 'float', 'decimal' => is_float($value) ? $value : (float) $value, 'boolean' => is_bool($value) ? $value : (boolean) $value, default => NULL, };