Skip to content

Commit

Permalink
bug #6221 Fix InvalidOptionsException when using ChoiceField with zer…
Browse files Browse the repository at this point in the history
…o choices (alshenetsky)

This PR was merged into the 4.x branch.

Discussion
----------

Fix InvalidOptionsException when using ChoiceField with zero choices

fix #6220

Commits
-------

ab54edb fix #6220
  • Loading branch information
javiereguiluz committed Mar 25, 2024
2 parents 0b8ff58 + ab54edb commit 1327179
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Field/Configurator/ChoiceConfigurator.php
Expand Up @@ -65,7 +65,7 @@ public function configure(FieldDto $field, EntityDto $entityDto, AdminContext $c
$areChoicesTranslatable = $choicesSupportTranslatableInterface = true;
}

if ($allChoicesAreEnums && array_is_list($choices)) {
if ($allChoicesAreEnums && array_is_list($choices) && \count($choices) > 0) {
$processedEnumChoices = [];
foreach ($choices as $choice) {
$processedEnumChoices[$choice->name] = $choice;
Expand Down

0 comments on commit 1327179

Please sign in to comment.