@@ -269,14 +269,14 @@ Look at the ``form_label`` as an example:
269269 {{ attrname }}="{{ attrvalue }}"
270270 {%- endfor %}
271271 >
272- {{ label|trans({} , translation_domain) }}
272+ {{ label|trans(translation_parameters , translation_domain) }}
273273 </label>
274274 {% endblock form_label %}
275275
276276 This block makes use of several variables: ``compound ``, ``label_attr ``,
277- ``required ``, ``label ``, ``name `` and ``translation_domain ``. These variables
278- are made available by the form rendering system. But more importantly, these
279- are the variables that you can override when calling ``form_label() `` (since
277+ ``required ``, ``label ``, ``name ``, `` translation_parameters `` and ``translation_domain ``.
278+ These variables are made available by the form rendering system. But more importantly,
279+ these are the variables that you can override when calling ``form_label() `` (since
280280in this example, you're rendering the label).
281281
282282The exact variables available to override depends on which part of the form
@@ -326,59 +326,61 @@ done by using a public ``vars`` property on the
326326 {{ form.name.vars.label }}
327327 </label>
328328
329- +------------------------+-------------------------------------------------------------------------------------+
330- | Variable | Usage |
331- +========================+=====================================================================================+
332- | ``form `` | The current ``FormView `` instance. |
333- +------------------------+-------------------------------------------------------------------------------------+
334- | ``id `` | The ``id `` HTML attribute to be rendered. |
335- +------------------------+-------------------------------------------------------------------------------------+
336- | ``name `` | The name of the field (e.g. ``title ``) - but not the ``name `` |
337- | | HTML attribute, which is ``full_name ``. |
338- +------------------------+-------------------------------------------------------------------------------------+
339- | ``full_name `` | The ``name `` HTML attribute to be rendered. |
340- +------------------------+-------------------------------------------------------------------------------------+
341- | ``errors `` | An array of any errors attached to *this * specific field |
342- | | (e.g. ``form.title.errors ``). |
343- | | Note that you can't use ``form.errors `` to determine if a form is valid, |
344- | | since this only returns "global" errors: some individual fields may have errors. |
345- | | Instead, use the ``valid `` option. |
346- +------------------------+-------------------------------------------------------------------------------------+
347- | ``submitted `` | Returns ``true `` or ``false `` depending on whether the whole form is submitted |
348- +------------------------+-------------------------------------------------------------------------------------+
349- | ``valid `` | Returns ``true `` or ``false `` depending on whether the whole form is valid. |
350- +------------------------+-------------------------------------------------------------------------------------+
351- | ``value `` | The value that will be used when rendering (commonly the ``value `` HTML attribute). |
352- +------------------------+-------------------------------------------------------------------------------------+
353- | ``disabled `` | If ``true ``, ``disabled="disabled" `` is added to the field. |
354- +------------------------+-------------------------------------------------------------------------------------+
355- | ``required `` | If ``true ``, a ``required `` attribute is added to the field to activate HTML5 |
356- | | validation. Additionally, a ``required `` class is added to the label. |
357- +------------------------+-------------------------------------------------------------------------------------+
358- | ``label `` | The string label that will be rendered. |
359- +------------------------+-------------------------------------------------------------------------------------+
360- | ``multipart `` | If ``true ``, ``form_enctype `` will render ``enctype="multipart/form-data" ``. |
361- | | This only applies to the root form element. |
362- +------------------------+-------------------------------------------------------------------------------------+
363- | ``attr `` | A key-value array that will be rendered as HTML attributes on the field. |
364- +------------------------+-------------------------------------------------------------------------------------+
365- | ``label_attr `` | A key-value array that will be rendered as HTML attributes on the label. |
366- +------------------------+-------------------------------------------------------------------------------------+
367- | ``compound `` | Whether or not a field is actually a holder for a group of children fields |
368- | | (for example, a ``choice `` field, which is actually a group of checkboxes. |
369- +------------------------+-------------------------------------------------------------------------------------+
370- | ``block_prefixes `` | An array of all the names of the parent types. |
371- +------------------------+-------------------------------------------------------------------------------------+
372- | ``translation_domain `` | The domain of the translations for this form. |
373- +------------------------+-------------------------------------------------------------------------------------+
374- | ``cache_key `` | A unique key which is used for caching. |
375- +------------------------+-------------------------------------------------------------------------------------+
376- | ``data `` | The normalized data of the type. |
377- +------------------------+-------------------------------------------------------------------------------------+
378- | ``method `` | The method of the current form (POST, GET, etc.). |
379- +------------------------+-------------------------------------------------------------------------------------+
380- | ``action `` | The action of the current form. |
381- +------------------------+-------------------------------------------------------------------------------------+
329+ +----------------------------+-------------------------------------------------------------------------------------+
330+ | Variable | Usage |
331+ +============================+=====================================================================================+
332+ | ``form `` | The current ``FormView `` instance. |
333+ +----------------------------+-------------------------------------------------------------------------------------+
334+ | ``id `` | The ``id `` HTML attribute to be rendered. |
335+ +----------------------------+-------------------------------------------------------------------------------------+
336+ | ``name `` | The name of the field (e.g. ``title ``) - but not the ``name `` |
337+ | | HTML attribute, which is ``full_name ``. |
338+ +----------------------------+-------------------------------------------------------------------------------------+
339+ | ``full_name `` | The ``name `` HTML attribute to be rendered. |
340+ +----------------------------+-------------------------------------------------------------------------------------+
341+ | ``errors `` | An array of any errors attached to *this * specific field |
342+ | | (e.g. ``form.title.errors ``). |
343+ | | Note that you can't use ``form.errors `` to determine if a form is valid, |
344+ | | since this only returns "global" errors: some individual fields may have errors. |
345+ | | Instead, use the ``valid `` option. |
346+ +----------------------------+-------------------------------------------------------------------------------------+
347+ | ``submitted `` | Returns ``true `` or ``false `` depending on whether the whole form is submitted |
348+ +----------------------------+-------------------------------------------------------------------------------------+
349+ | ``valid `` | Returns ``true `` or ``false `` depending on whether the whole form is valid. |
350+ +----------------------------+-------------------------------------------------------------------------------------+
351+ | ``value `` | The value that will be used when rendering (commonly the ``value `` HTML attribute). |
352+ +----------------------------+-------------------------------------------------------------------------------------+
353+ | ``disabled `` | If ``true ``, ``disabled="disabled" `` is added to the field. |
354+ +----------------------------+-------------------------------------------------------------------------------------+
355+ | ``required `` | If ``true ``, a ``required `` attribute is added to the field to activate HTML5 |
356+ | | validation. Additionally, a ``required `` class is added to the label. |
357+ +----------------------------+-------------------------------------------------------------------------------------+
358+ | ``label `` | The string label that will be rendered. |
359+ +----------------------------+-------------------------------------------------------------------------------------+
360+ | ``multipart `` | If ``true ``, ``form_enctype `` will render ``enctype="multipart/form-data" ``. |
361+ | | This only applies to the root form element. |
362+ +----------------------------+-------------------------------------------------------------------------------------+
363+ | ``attr `` | A key-value array that will be rendered as HTML attributes on the field. |
364+ +----------------------------+-------------------------------------------------------------------------------------+
365+ | ``label_attr `` | A key-value array that will be rendered as HTML attributes on the label. |
366+ +----------------------------+-------------------------------------------------------------------------------------+
367+ | ``compound `` | Whether or not a field is actually a holder for a group of children fields |
368+ | | (for example, a ``choice `` field, which is actually a group of checkboxes. |
369+ +----------------------------+-------------------------------------------------------------------------------------+
370+ | ``block_prefixes `` | An array of all the names of the parent types. |
371+ +----------------------------+-------------------------------------------------------------------------------------+
372+ | ``translation_domain `` | The domain of the translations for this form. |
373+ +----------------------------+-------------------------------------------------------------------------------------+
374+ | ``translation_parameters `` | An array of translation parameters for this form. |
375+ +----------------------------+-------------------------------------------------------------------------------------+
376+ | ``cache_key `` | A unique key which is used for caching. |
377+ +----------------------------+-------------------------------------------------------------------------------------+
378+ | ``data `` | The normalized data of the type. |
379+ +----------------------------+-------------------------------------------------------------------------------------+
380+ | ``method `` | The method of the current form (POST, GET, etc.). |
381+ +----------------------------+-------------------------------------------------------------------------------------+
382+ | ``action `` | The action of the current form. |
383+ +----------------------------+-------------------------------------------------------------------------------------+
382384
383385.. _`form_div_layout.html.twig` : https://github.com/symfony/symfony/blob/master/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig
384386.. _`the Twig documentation` : https://twig.symfony.com/doc/2.x/templates.html#test-operator
0 commit comments