Skip to content

Commit bb06b33

Browse files
committed
Reword
1 parent 7392fc2 commit bb06b33

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

reference/forms/types/choice.rst

+10-13
Original file line numberDiff line numberDiff line change
@@ -321,20 +321,16 @@ Field Variables
321321

322322
.. tip::
323323

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.
326326

327+
Accessing Form Choice Data
328+
...........................
327329

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``::
338334

339335
.. code-block:: html+twig
340336

@@ -347,7 +343,8 @@ Given the advanced object example, each entry would have access to the following
347343
{# a map of `ChoiceView` or `ChoiceGroupView` instances indexed by choice values or group names #}
348344
{{ form.parent.vars.choices }}
349345

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``::
351348

352349
.. code-block:: html+twig
353350

0 commit comments

Comments
 (0)