Skip to content

Commit 776ae4c

Browse files
committed
[#1039][#2251] Updating the Form variables section with the new 2.1 variable
1 parent 6b04895 commit 776ae4c

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

reference/forms/twig_reference.rst

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,10 @@ object:
230230
<?php echo $view['form']->get('name')->vars['label'] ?>
231231
</label>
232232

233+
.. versionadded:: 2.1
234+
The ``valid``, ``label_attr``, ``compound``, and ``disabled`` variables
235+
are new in Symfony 2.1.
236+
233237
+-----------------+-----------------------------------------------------------------------------------------+
234238
| Variable | Usage |
235239
+=================+=========================================================================================+
@@ -243,10 +247,15 @@ object:
243247
| ``errors`` | An array of any errors attached to *this* specific field (e.g. ``form.title.errors``). |
244248
| | Note that you can't use ``form.errors`` to determine if a form is valid, |
245249
| | since this only returns "global" errors: some individual fields may have errors |
250+
| | Instead, use the ``valid`` option |
251+
+-----------------+-----------------------------------------------------------------------------------------+
252+
| ``valid`` | Returns ``true`` or ``false`` depending on whether the whole form is valid |
246253
+-----------------+-----------------------------------------------------------------------------------------+
247254
| ``value`` | The value that will be used when rendering (commonly the ``value`` HTML attribute) |
248255
+-----------------+-----------------------------------------------------------------------------------------+
249-
| ``read_only`` | If ``true``, ``disabled="disabled"`` is added to the field |
256+
| ``read_only`` | If ``true``, ``readonly="readonly"`` is added to the field |
257+
+-----------------+-----------------------------------------------------------------------------------------+
258+
| ``disabled`` | If ``true``, ``disabled="disabled"`` is added to the field |
250259
+-----------------+-----------------------------------------------------------------------------------------+
251260
| ``required`` | If ``true``, a ``required`` attribute is added to the field to activate HTML5 |
252261
| | validation. Additionally, a ``required`` class is added to the label. |
@@ -262,5 +271,10 @@ object:
262271
+-----------------+-----------------------------------------------------------------------------------------+
263272
| ``attr`` | A key-value array that will be rendered as HTML attributes on the field |
264273
+-----------------+-----------------------------------------------------------------------------------------+
274+
| ``label_attr`` | A key-value array that will be rendered as HTML attributes on the label |
275+
+-----------------+-----------------------------------------------------------------------------------------+
276+
| ``compound`` | Whether or not a field is actually a holder for a group of children fields |
277+
| | (for example, a ``choice`` field, which is actually a group of checkboxes |
278+
+-----------------+-----------------------------------------------------------------------------------------+
265279

266280
.. _`form_div_layout.html.twig`: https://github.com/symfony/symfony/blob/2.1/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig

0 commit comments

Comments
 (0)