From a57c428a7c92f121a3b8eae2955988e5a05437b8 Mon Sep 17 00:00:00 2001 From: Simon Asika Date: Sun, 11 Sep 2022 13:59:49 +0800 Subject: [PATCH] ListField::registerFromEnums() if no title, show value or key name #985 --- packages/form/src/Field/Concern/ListOptionsTrait.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/form/src/Field/Concern/ListOptionsTrait.php b/packages/form/src/Field/Concern/ListOptionsTrait.php index 4d3669a1c..5a0a9350e 100644 --- a/packages/form/src/Field/Concern/ListOptionsTrait.php +++ b/packages/form/src/Field/Concern/ListOptionsTrait.php @@ -142,7 +142,7 @@ public function registerFromEnums(iterable|string $enums, ?LanguageInterface $la foreach ($enums as $enum) { if ($enum instanceof EnumTranslatableInterface) { - $options[$enum->getValue()] = $enum->getTitle($lang); + $options[$enum->getValue()] = $enum->getTitle($lang) ?: $enum->getKey(); } elseif ($enum instanceof Enum) { $options[$enum->getValue()] = $enum->getKey(); } elseif ($enum instanceof \UnitEnum) {