Skip to content

Commit

Permalink
[Autocomplete] Fix choice_value bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ytilotti authored Dec 11, 2023
1 parent a3de399 commit b5292d2
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Autocomplete/src/Form/WrappedEntityTypeAutocompleter.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,17 @@ public function getLabel(object $entity): string

public function getValue(object $entity): string
{
return $this->getEntityMetadata()->getIdValue($entity);
$choiceValue = $this->getFormOption('choice_value');

if (\is_string($choiceValue) || $choiceValue instanceof PropertyPathInterface) {
return $this->propertyAccessor->getValue($entity, $choiceValue);
}

if ($choiceValue instanceof Cache\ChoiceValue) {
$choiceValue = $choiceValue->getOption();
}

return $choiceValue($entity);
}

public function isGranted(Security $security): bool
Expand Down

0 comments on commit b5292d2

Please sign in to comment.