Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

EntityType does not select preferred choices #61562

Unanswered
Peter-Harbig asked this question in Q&A
Discussion options

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?

You must be logged in to vote

Replies: 2 comments

Comment options

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.

You must be logged in to vote
0 replies
Comment options

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.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /