-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
EntityType does not select preferred choices #61562
-
In Symfony 7.2.3 I have a EntityType field in my form where I'm using preferred choices. The underlying data and the preferred choices are the same: 'data' => $options['preferred_recipients'], and 'preferred_choices' => $options['preferred_recipients']'preferred_choices' => $options['preferred_recipients'] .
If the EntityType has 'duplicate_preferred_choices' => false, 'multiple' => true, and 'expanded' => false it does not select the preferred choices, but if I set 'duplicate_preferred_choices' => true or 'expanded' => true it does.
The piece of code :
$builder
->add('recipients', EntityType::class,
[
'class' => Guide::class,
'disabled' => $options['attributes_disabled'],
'duplicate_preferred_choices' => false,
'help' => new TranslatableMessage('attribute.recipients.help', [], 'tourinfo'),
'label' => new TranslatableMessage('attribute.recipients.label', [], 'tourinfo'),
'multiple' => true,
'expanded' => false,
'preferred_choices' => $options['preferred_recipients'],
'data' => $options['preferred_recipients'],
]
)
Did I make anything wrong or is it a bug within the Symfony EntityType?
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 2 comments
-
Just a correction: if I set 'duplicate_preferred_choices' => false the preferred choices will be set within the non-preferred part of the list, but not as preferred_choice.
Beta Was this translation helpful? Give feedback.
All reactions
-
I close it as it is working fine after some changes to the import map and adding new dependencies with composer. All of them have nothing to do with my problem, but it looks like the caches have been refreshed and the issue was gone.
Beta Was this translation helpful? Give feedback.