diff --git a/form/form_customization.rst b/form/form_customization.rst index d5c27e3aa53..97c6cabe744 100644 --- a/form/form_customization.rst +++ b/form/form_customization.rst @@ -24,12 +24,30 @@ enough to render an entire form, including all its fields and error messages: by calling to the $form->createView() method #} {{ form(form) }} -The next step is to use the :ref:`form_start() `, +As short as this rendering is, it's not very flexible. The next step is to use the +:ref:`form_start() `, :ref:`form_end() `, -:ref:`form_errors() ` and -:ref:`form_row() ` Twig functions to render the +:ref:`field_name() `, +:ref:`field_value() ` and +:ref:`field_errors() ` Twig functions to render the different form parts so you can customize them adding HTML elements and attributes: +// TODO + +Generic Form Rendering +---------------------- + +If you want to let the PHP code defining the structure of the form also describes +how it should be displayed (for instance in the case of a reusable PHP package), +you may want to rely on generic form rendering instead of individual Twig functions. + +To do so, you can use the +:ref:`form_row() `, +:ref:`form_widget() `, +:ref:`form_errors() ` and +:ref:`form_rest() ` +Twig functions to render the form parts generically: + .. code-block:: html+twig {{ form_start(form) }} @@ -74,6 +92,9 @@ control over how each form field is rendered, so you can fully customize them: +Using these generic functions to render forms allow PHP code and general form themes to affect +the way your fields will be displayed. + .. note:: Later in this article you can find the full reference of these Twig diff --git a/reference/twig_reference.rst b/reference/twig_reference.rst index b70dbb0e0aa..bed8a3ae36b 100644 --- a/reference/twig_reference.rst +++ b/reference/twig_reference.rst @@ -342,6 +342,12 @@ explained in the article about :doc:`customizing form rendering ` * :ref:`form_row() ` * :ref:`form_rest() ` +* :ref:`field_name() ` +* :ref:`field_value() ` +* :ref:`field_label() ` +* :ref:`field_help() ` +* :ref:`field_errors() ` +* :ref:`field_choices() ` .. _reference-twig-filters: