@@ -321,20 +321,16 @@ Field Variables
321
321
322
322
.. tip ::
323
323
324
- It's significantly faster to use the :ref: ` selectedchoice < form-twig-selectedchoice >`
325
- test instead when using Twig .
324
+ In Twig template, instead of using `` is_selected() ``, it's significantly
325
+ faster to use the :ref: ` selectedchoice < form-twig-selectedchoice >` test .
326
326
327
+ Accessing Form Choice Data
328
+ ...........................
327
329
328
- Access data in a Form Choice
329
- .............................
330
-
331
- When you use an expanded ``ChoiceType `` and need to customize the children ``entry `` blocks,
332
- the ``form.vars `` of entries (radio button or checkbox) may not be enough since each holds a
333
- boolean value meaning whether a choice is selected or not.
334
- To get the full list of choices data and values, you will need to access the ``choices `` variable
335
- from their parent form (the ``ChoiceType `` itself) with ``form.parent.vars.choices ``::
336
-
337
- Given the advanced object example, each entry would have access to the following variables:
330
+ The ``form.vars `` variable of each choice entry holds data such as whether the
331
+ choice is selected or not. If you need to get the full list of choices data and
332
+ values, use the ``choices `` variable from the parent form of the choice entry
333
+ (which is the ``ChoiceType `` itself) with ``form.parent.vars.choices ``::
338
334
339
335
.. code-block :: html+twig
340
336
@@ -347,7 +343,8 @@ Given the advanced object example, each entry would have access to the following
347
343
{# a map of `ChoiceView ` or `ChoiceGroupView ` instances indexed by choice values or group names #}
348
344
{{ form.parent.vars.choices }}
349
345
350
- So the Category's entity is inside ``form.parent.vars.choices[key].data ``, because the parent knows all the choices.
346
+ Following the same advanced example as above (where choices values are entities),
347
+ the ``Category `` object is inside ``form.parent.vars.choices[key].data ``::
351
348
352
349
.. code-block :: html+twig
353
350
0 commit comments