File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -151,6 +151,34 @@ values::
151
151
This will restrict the ``delivery `` options to be either ``standard ``,
152
152
``expedited `` or ``priority ``.
153
153
154
+ You can also provide enum values to ``enumNode() ``. Let's define an enumeration
155
+ describing the possible states of the example above::
156
+
157
+ enum Delivery: string
158
+ {
159
+ case Standard = 'standard';
160
+ case Expedited = 'expedited';
161
+ case Priority = 'priority';
162
+ }
163
+
164
+ The configuration can now be written like this::
165
+
166
+ $rootNode
167
+ ->children()
168
+ ->enumNode('delivery')
169
+ // You can provide all values of the enum...
170
+ ->values(Delivery::cases())
171
+ // ... or you can pass only some values next to other scalar values
172
+ ->values([Delivery::Priority, Delivery::Standard, 'other', false])
173
+ ->end()
174
+ ->end()
175
+ ;
176
+
177
+ .. versionadded :: 6.3
178
+
179
+ The support of enum values in ``enumNode() `` was introduced
180
+ in Symfony 6.3.
181
+
154
182
Array Nodes
155
183
~~~~~~~~~~~
156
184
You can’t perform that action at this time.
0 commit comments