From cf2cc488d6f9836ac3c2cc8e98906142c8aed45b Mon Sep 17 00:00:00 2001 From: firas Bedoui Date: Thu, 17 Aug 2023 16:04:56 +0200 Subject: [PATCH 1/2] Fix display of enums for nullable property --- src/Resources/views/CRUD/display_enum.html.twig | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Resources/views/CRUD/display_enum.html.twig b/src/Resources/views/CRUD/display_enum.html.twig index 5b5d7d9734..0f1d3cd139 100644 --- a/src/Resources/views/CRUD/display_enum.html.twig +++ b/src/Resources/views/CRUD/display_enum.html.twig @@ -10,13 +10,16 @@ file that was distributed with this source code. #} {%- apply spaceless %} - {% set value = use_value|default(false) ? value.value : value.name %} - - {% if translation_domain|default(null) is null %} - {% set value = value %} + {% if value is null %} +   {% else %} - {% set value = value|trans({}, translation_domain) %} - {% endif %} + {% set value = use_value|default(false) ? value.value : value.name %} - {{ value }} + {% if translation_domain|default(null) is null %} + {% set value = value %} + {% else %} + {% set value = value|trans({}, translation_domain) %} + {% endif %} + {{ value }} + {% endif %} {% endapply -%} From 223944adedb870fef1720c5f1e9776ea12721930 Mon Sep 17 00:00:00 2001 From: firas Bedoui Date: Mon, 28 Aug 2023 09:21:37 +0200 Subject: [PATCH 2/2] Add test for enums nullable property --- tests/Twig/Extension/RenderElementExtensionTest.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/Twig/Extension/RenderElementExtensionTest.php b/tests/Twig/Extension/RenderElementExtensionTest.php index a40f598a14..77d1877a3e 100644 --- a/tests/Twig/Extension/RenderElementExtensionTest.php +++ b/tests/Twig/Extension/RenderElementExtensionTest.php @@ -1513,6 +1513,13 @@ class="x-editable" return $elements; } + $elements[] = [ + '   ', + FieldDescriptionInterface::TYPE_ENUM, + null, + [], + ]; + $elements[] = [ ' Hearts ', FieldDescriptionInterface::TYPE_ENUM,