Skip to content

Commit

Permalink
5984 fix finding selected enum value in choices
Browse files Browse the repository at this point in the history
  • Loading branch information
klkvsk committed Nov 1, 2023
1 parent bf76d49 commit a94b7a0
Show file tree
Hide file tree
Showing 4 changed files with 290 additions and 288 deletions.
5 changes: 5 additions & 0 deletions src/Field/Configurator/ChoiceConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ public function configure(FieldDto $field, EntityDto $entityDto, AdminContext $c
// Translatable choice don't need to get flipped
$flippedChoices = $areChoicesTranslatable ? $choices : array_flip($this->flatten($choices));
foreach ((array) $fieldValue as $selectedValue) {
if ($selectedValue instanceof \BackedEnum) {
$selectedValue = $selectedValue->value;
} elseif ($selectedValue instanceof \UnitEnum) {
$selectedValue = $selectedValue->name;
}
if (null !== $selectedLabel = $flippedChoices[$selectedValue] ?? null) {
if ($selectedLabel instanceof TranslatableInterface) {
$choiceMessage = $selectedLabel;
Expand Down
4 changes: 2 additions & 2 deletions src/Resources/public/app.052a1081.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/Resources/public/app.052a1081.rtl.css

Large diffs are not rendered by default.

Loading

0 comments on commit a94b7a0

Please sign in to comment.