Skip to content

[Form] Mentioned the change in the "preferred choices" behavior #12038

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 26, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions reference/forms/types/options/preferred_choices.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ preferred_choices

**type**: ``array``, ``callable`` or ``string`` **default**: ``[]``

This option allows you to move certain choices to the top of your list with a visual
separator between them and the rest of the options. If you have a form of languages,
you can list the most popular on top, like Bork Bork and Pirate::
This option allows you to display certain choices at the top of your list with a
visual separator between them and the complete list of options. If you have a
form of languages, you can list the most popular on top, like Bork Bork and Pirate::

use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
// ...
Expand All @@ -20,6 +20,12 @@ you can list the most popular on top, like Bork Bork and Pirate::
'preferred_choices' => ['muppets', 'arr'],
]);

.. versionadded:: 4.4

Starting from Symfony 4.4, the preferred choices are displayed both at the
top of the list and at their original locations on the list. In prior
Symfony versions, they were only displayed at the top of the list.

This options can also be a callback function to give you more flexibility. This might
be especially useful if your values are objects::

Expand Down