Skip to content

Commit 945cd49

Browse files
committed
Fix choice_label compatibility with Symfony < 8.1
Don't pass null choice_label explicitly to EntityType as it behaves differently than omitting the option in older Symfony versions.
1 parent 58d2925 commit 945cd49

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Form/EventListener/CrudAutocompleteSubscriber.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ public function preSetData(FormEvent $event)
7070
$options['autocomplete_template']
7171
);
7272

73+
// Don't pass null choice_label to EntityType - let it use __toString() default
74+
// (passing null explicitly behaves differently than omitting the option in Symfony < 8.1)
75+
if (null === ($options['choice_label'] ?? null)) {
76+
unset($options['choice_label']);
77+
}
78+
7379
$form->add('autocomplete', EntityType::class, $options);
7480
}
7581

0 commit comments

Comments
 (0)