Skip to content

Commit 5802b05

Browse files
committed
[Form] Document the choices option of EnumType
1 parent b878bfe commit 5802b05

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

reference/forms/types/enum.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,25 @@ Inherited Options
100100

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

103+
choices
104+
~~~~~~~
105+
106+
**type**: ``array`` **default**: ``[]``
107+
108+
By default, this fields displays all the cases of the related PHP enum. Use this
109+
option to define explicitly which options to display::
110+
111+
use App\Config\TextAlign;
112+
use Symfony\Component\Form\Extension\Core\Type\EnumType;
113+
// ...
114+
115+
$builder->add('alignment', EnumType::class, [
116+
'choices' => [
117+
TextAlign::Left,
118+
TextAlign::Right,
119+
],
120+
]);
121+
103122
.. include:: /reference/forms/types/options/choice_attr.rst.inc
104123

105124
.. include:: /reference/forms/types/options/choice_filter.rst.inc

0 commit comments

Comments
 (0)