From 6a2689e0cea44cf5faea4b7face9ed88ce4da999 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 8 Feb 2023 20:18:52 +0100 Subject: [PATCH] Fix some issues in Choice field with PHP Enums --- src/Field/Configurator/ChoiceConfigurator.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Field/Configurator/ChoiceConfigurator.php b/src/Field/Configurator/ChoiceConfigurator.php index 104b5a4ace..8a90f24efd 100644 --- a/src/Field/Configurator/ChoiceConfigurator.php +++ b/src/Field/Configurator/ChoiceConfigurator.php @@ -10,6 +10,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField; use EasyCorp\Bundle\EasyAdminBundle\Translation\TranslatableChoiceMessage; use EasyCorp\Bundle\EasyAdminBundle\Translation\TranslatableChoiceMessageCollection; +use Symfony\Component\Form\Extension\Core\Type\EnumType; use function Symfony\Component\String\u; use function Symfony\Component\Translation\t; use Symfony\Contracts\Translation\TranslatableInterface; @@ -55,6 +56,8 @@ public function configure(FieldDto $field, EntityDto $entityDto, AdminContext $c $allChoicesAreEnums = false === \in_array(false, $elementIsEnum, true); if ($allChoicesAreEnums) { + $field->setFormType(EnumType::class); + $processedEnumChoices = []; foreach ($choices as $choice) { if ($choice instanceof \BackedEnum) {