Skip to content

Commit a55c4b7

Browse files
committed
Merge branch '6.4' into 7.3
* 6.4: [Form] Document the choices option of EnumType
2 parents 7c9046d + fe70fe0 commit a55c4b7

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
@@ -94,6 +94,25 @@ Inherited Options
9494

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

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

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

0 commit comments

Comments
 (0)