Skip to content

Commit

Permalink
fix(core/form): choice with linked collection (ems-project#742)
Browse files Browse the repository at this point in the history
  • Loading branch information
theus77 authored Feb 1, 2024
1 parent f1896e9 commit 7b5bffa
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions EMS/core-bundle/src/Form/DataField/ChoiceFieldType.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,8 @@ public function reverseViewTransform($data, FieldType $fieldType): DataField
{
$value = $data['value'] ?? null;
if (\is_array($value)) {
$choices = $fieldType->getDisplayOption('choices', '');
$values = \explode("\n", \str_replace("\r", '', (string) $choices));
$value = \array_values(\array_filter($values, static fn ($v) => \in_array($v, $value, true)));
$choices = $this->buildChoices($fieldType->getDisplayOptions());
$value = \array_values(\array_filter($value, static fn ($v) => \in_array($v, $choices, true)));
}

return parent::reverseViewTransform($value, $fieldType);
Expand Down

0 comments on commit 7b5bffa

Please sign in to comment.