Skip to content

Commit db456df

Browse files
committed
Merge branch '7.4' into 8.0
* 7.4: [Form] Document the choices option of EnumType
2 parents 18900f0 + 4a96973 commit db456df

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)