Skip to content

Commit d2b57be

Browse files
committed
Documented missing FormType variables
1 parent d974c77 commit d2b57be

File tree

1 file changed

+60
-42
lines changed

1 file changed

+60
-42
lines changed

reference/forms/twig_reference.rst

Lines changed: 60 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -295,47 +295,65 @@ object:
295295
<?php echo $view['form']->get('name')->vars['label'] ?>
296296
</label>
297297

298-
+-----------------+-----------------------------------------------------------------------------------------+
299-
| Variable | Usage |
300-
+=================+=========================================================================================+
301-
| ``id`` | The ``id`` HTML attribute to be rendered |
302-
+-----------------+-----------------------------------------------------------------------------------------+
303-
| ``name`` | The name of the field (e.g. ``title``) - but not the ``name`` |
304-
| | HTML attribute, which is ``full_name`` |
305-
+-----------------+-----------------------------------------------------------------------------------------+
306-
| ``full_name`` | The ``name`` HTML attribute to be rendered |
307-
+-----------------+-----------------------------------------------------------------------------------------+
308-
| ``errors`` | An array of any errors attached to *this* specific field (e.g. ``form.title.errors``). |
309-
| | Note that you can't use ``form.errors`` to determine if a form is valid, |
310-
| | since this only returns "global" errors: some individual fields may have errors |
311-
| | Instead, use the ``valid`` option |
312-
+-----------------+-----------------------------------------------------------------------------------------+
313-
| ``valid`` | Returns ``true`` or ``false`` depending on whether the whole form is valid |
314-
+-----------------+-----------------------------------------------------------------------------------------+
315-
| ``value`` | The value that will be used when rendering (commonly the ``value`` HTML attribute) |
316-
+-----------------+-----------------------------------------------------------------------------------------+
317-
| ``read_only`` | If ``true``, ``readonly="readonly"`` is added to the field |
318-
+-----------------+-----------------------------------------------------------------------------------------+
319-
| ``disabled`` | If ``true``, ``disabled="disabled"`` is added to the field |
320-
+-----------------+-----------------------------------------------------------------------------------------+
321-
| ``required`` | If ``true``, a ``required`` attribute is added to the field to activate HTML5 |
322-
| | validation. Additionally, a ``required`` class is added to the label. |
323-
+-----------------+-----------------------------------------------------------------------------------------+
324-
| ``max_length`` | Adds a ``maxlength`` HTML attribute to the element |
325-
+-----------------+-----------------------------------------------------------------------------------------+
326-
| ``pattern`` | Adds a ``pattern`` HTML attribute to the element |
327-
+-----------------+-----------------------------------------------------------------------------------------+
328-
| ``label`` | The string label that will be rendered |
329-
+-----------------+-----------------------------------------------------------------------------------------+
330-
| ``multipart`` | If ``true``, ``form_enctype`` will render ``enctype="multipart/form-data"``. |
331-
| | This only applies to the root form element. |
332-
+-----------------+-----------------------------------------------------------------------------------------+
333-
| ``attr`` | A key-value array that will be rendered as HTML attributes on the field |
334-
+-----------------+-----------------------------------------------------------------------------------------+
335-
| ``label_attr`` | A key-value array that will be rendered as HTML attributes on the label |
336-
+-----------------+-----------------------------------------------------------------------------------------+
337-
| ``compound`` | Whether or not a field is actually a holder for a group of children fields |
338-
| | (for example, a ``choice`` field, which is actually a group of checkboxes |
339-
+-----------------+-----------------------------------------------------------------------------------------+
298+
.. versionadded:: 2.3
299+
The ``method`` and ``action`` variables were introduced in Symfony 2.3.
300+
301+
+------------------------+-------------------------------------------------------------------------------------+
302+
| Variable | Usage |
303+
+========================+=====================================================================================+
304+
| ``form`` | The current FormView instance |
305+
+------------------------+-------------------------------------------------------------------------------------+
306+
| ``id`` | The ``id`` HTML attribute to be rendered |
307+
+------------------------+-------------------------------------------------------------------------------------+
308+
| ``name`` | The name of the field (e.g. ``title``) - but not the ``name`` |
309+
| | HTML attribute, which is ``full_name`` |
310+
+------------------------+-------------------------------------------------------------------------------------+
311+
| ``full_name`` | The ``name`` HTML attribute to be rendered |
312+
+------------------------+-------------------------------------------------------------------------------------+
313+
| ``errors`` | An array of any errors attached to *this* specific field |
314+
| | (e.g. ``form.title.errors``). |
315+
| | Note that you can't use ``form.errors`` to determine if a form is valid, |
316+
| | since this only returns "global" errors: some individual fields may have errors |
317+
| | Instead, use the ``valid`` option |
318+
+------------------------+-------------------------------------------------------------------------------------+
319+
| ``valid`` | Returns ``true`` or ``false`` depending on whether the whole form is valid |
320+
+------------------------+-------------------------------------------------------------------------------------+
321+
| ``value`` | The value that will be used when rendering (commonly the ``value`` HTML attribute) |
322+
+------------------------+-------------------------------------------------------------------------------------+
323+
| ``read_only`` | If ``true``, ``readonly="readonly"`` is added to the field |
324+
+------------------------+-------------------------------------------------------------------------------------+
325+
| ``disabled`` | If ``true``, ``disabled="disabled"`` is added to the field |
326+
+------------------------+-------------------------------------------------------------------------------------+
327+
| ``required`` | If ``true``, a ``required`` attribute is added to the field to activate HTML5 |
328+
| | validation. Additionally, a ``required`` class is added to the label. |
329+
+------------------------+-------------------------------------------------------------------------------------+
330+
| ``max_length`` | Adds a ``maxlength`` HTML attribute to the element |
331+
+------------------------+-------------------------------------------------------------------------------------+
332+
| ``pattern`` | Adds a ``pattern`` HTML attribute to the element |
333+
+------------------------+-------------------------------------------------------------------------------------+
334+
| ``label`` | The string label that will be rendered |
335+
+------------------------+-------------------------------------------------------------------------------------+
336+
| ``multipart`` | If ``true``, ``form_enctype`` will render ``enctype="multipart/form-data"``. |
337+
| | This only applies to the root form element. |
338+
+------------------------+-------------------------------------------------------------------------------------+
339+
| ``attr`` | A key-value array that will be rendered as HTML attributes on the field |
340+
+------------------------+-------------------------------------------------------------------------------------+
341+
| ``label_attr`` | A key-value array that will be rendered as HTML attributes on the label |
342+
+------------------------+-------------------------------------------------------------------------------------+
343+
| ``compound`` | Whether or not a field is actually a holder for a group of children fields |
344+
| | (for example, a ``choice`` field, which is actually a group of checkboxes |
345+
+------------------------+-------------------------------------------------------------------------------------+
346+
| ``block_prefixes`` | An array of all the names of the parent types |
347+
+------------------------+-------------------------------------------------------------------------------------+
348+
| ``translation_domain`` | The domain of the translations for this form |
349+
+------------------------+-------------------------------------------------------------------------------------+
350+
| ``cache_key`` | An unique key which is used for caching |
351+
+------------------------+-------------------------------------------------------------------------------------+
352+
| ``data`` | The normalized data of the type |
353+
+------------------------+-------------------------------------------------------------------------------------+
354+
| ``method`` | The method of the current form (POST, GET, etc) |
355+
+------------------------+-------------------------------------------------------------------------------------+
356+
| ``action`` | The action of the current form (POST, GET, etc) |
357+
+------------------------+-------------------------------------------------------------------------------------+
340358

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

0 commit comments

Comments
 (0)