8000 [Form] Add `duplicate_preferred_choices` option to `ChoiceType` · symfony/symfony-docs@2ec5104 · GitHub
[go: up one dir, main page]

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

Appearance settings

Commit 2ec5104

Browse files
[Form] Add duplicate_preferred_choices option to ChoiceType
1 parent baedc81 commit 2ec5104

File tree

8 files changed

+41
-0
lines changed

8 files changed

+41
-0
lines changed

reference/forms/types/choice.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ correct types will be assigned to the model.
188188

189189
.. include:: /reference/forms/types/options/choice_value.rst.inc
190190

191+
.. include:: /reference/forms/types/options/duplicate_preferred_choices.rst.inc
192+
191193
.. include:: /reference/forms/types/options/expanded.rst.inc
192194

193195
.. include:: /reference/forms/types/options/group_by.rst.inc

reference/forms/types/country.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ Inherited Options
6868

6969
These options inherit from the :doc:`ChoiceType </reference/forms/types/choice>`:
7070

71+
.. include:: /reference/forms/types/options/duplicate_preferred_choices.rst.inc
72+
7173
.. include:: /reference/forms/types/options/error_bubbling.rst.inc
7274

7375
.. include:: /reference/forms/types/options/error_mapping.rst.inc

reference/forms/types/currency.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ Inherited Options
5151

5252
These options inherit from the :doc:`ChoiceType </reference/forms/types/choice>`:
5353

54+
.. include:: /reference/forms/types/options/duplicate_preferred_choices.rst.inc
55+
5456
.. include:: /reference/forms/types/options/error_bubbling.rst.inc
5557

5658
.. include:: /reference/forms/types/options/expanded.rst.inc

reference/forms/types/enum.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ This callback will group choices in 3 categories: ``Upper``, ``Lower`` and ``Oth
159159

160160
If you return ``null``, the option won't be grouped.
161161

162+
.. include:: /reference/forms/types/options/duplicate_preferred_choices.rst.inc
163+
162164
.. include:: /reference/forms/types/options/multiple.rst.inc
163165

164166
.. include:: /reference/forms/types/options/placeholder.rst.inc

reference/forms/types/language.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ Inherited Options
8585

8686
These options inherit from the :doc:`ChoiceType </reference/forms/types/choice>`:
8787

88+
.. include:: /reference/forms/types/options/duplicate_preferred_choices.rst.inc
89+
8890
.. include:: /reference/forms/types/options/error_bubbling.rst.inc
8991

9092
.. include:: /reference/forms/types/options/error_mapping.rst.inc

reference/forms/types/locale.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ Inherited Options
6262

6363
These options inherit from the :doc:`ChoiceType </reference/forms/types/choice>`:
6464

65+
.. include:: /reference/forms/types/options/duplicate_preferred_choices.rst.inc
66+
6567
.. include:: /reference/forms/types/options/error_bubbling.rst.inc
6668

6769
.. include:: /reference/forms/types/options/error_mapping.rst.inc
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
``duplicate_preferred_choices``
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
**type**: ``boolean`` **default**: ``true``
5+
6+
When using the ``preferred_choices`` option, the selected choices are displayed
7+
twice by default: at the top of your list and in the complete list. You can
8+
change this behavior: when setting this option to ``false``, preferred choices
9+
will only be displayed at the top of the list.
10+
11+
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
12+
// ...
13+
14+
$builder->add('language', ChoiceType::class, [
15+
'choices' => [
16+
'English' => 'en',
17+
'Spanish' => 'es',
18+
'Bork' => 'muppets',
19+
'Pirate' => 'arr',
20+
],
21+
'preferred_choices' => ['muppets', 'arr'],
22+
'duplicate_preferred_choices' => false,
23+
]);
24+
25+
.. versionadded:: 6.4
26+
27+
The ``duplicate_preferred_choices`` option was introduced in Symfony 6.4.

reference/forms/types/timezone.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ Inherited Options
8383

8484
These options inherit from the :doc:`ChoiceType </reference/forms/types/choice>`:
8585

86+
.. include:: /reference/forms/types/options/duplicate_preferred_choices.rst.inc
87+
8688
.. include:: /reference/forms/types/options/expanded.rst.inc
8789

8890
.. include:: /reference/forms/types/options/multiple.rst.inc

0 commit comments

Comments
 (0)
0