Skip to content

Simplified the form theming docs #10926

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions _build/redirection_map
Original file line number Diff line number Diff line change
Expand Up @@ -403,3 +403,5 @@
/frontend/encore/installation-no-flex /frontend/encore/installation
/http_cache/form_csrf_caching /security/csrf
/console/logging /console
/reference/forms/twig_reference /form/form_customization
/form/rendering /form/form_customization
1 change: 1 addition & 0 deletions _images/form/form-field-parts.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _images/sources/form/form-field-parts.dia
Binary file not shown.
13 changes: 7 additions & 6 deletions components/form.rst
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,9 @@ between Twig and several Symfony components:

$ composer require symfony/twig-bridge

The TwigBridge integration provides you with several :doc:`Twig Functions </reference/forms/twig_reference>`
that help you render the HTML widget, label and error for each field
The TwigBridge integration provides you with several
:ref:`Twig Functions <reference-form-twig-functions-variables>`
that help you render the HTML widget, label, help and errors for each field
(as well as a few other things). To configure the integration, you'll need
to bootstrap or access Twig and add the :class:`Symfony\\Bridge\\Twig\\Extension\\FormExtension`::

Expand Down Expand Up @@ -231,7 +232,7 @@ The exact details of your `Twig Configuration`_ will vary, but the goal is
always to add the :class:`Symfony\\Bridge\\Twig\\Extension\\FormExtension`
to Twig, which gives you access to the Twig functions for rendering forms.
To do this, you first need to create a :class:`Symfony\\Bridge\\Twig\\Form\\TwigRendererEngine`,
where you define your :ref:`form themes <form-customization-form-themes>`
where you define your :doc:`form themes </form/form_themes>`
(i.e. resources/files that define form HTML markup).

For general details on rendering forms, see :doc:`/form/form_customization`.
Expand Down Expand Up @@ -510,8 +511,8 @@ Rendering the Form

Now that the form has been created, the next step is to render it. This is
done by passing a special form "view" object to your template (notice the
``$form->createView()`` in the controller above) and using a set of form
helper functions:
``$form->createView()`` in the controller above) and using a set of
:ref:`form helper functions <reference-form-twig-functions>`:

.. code-block:: html+twig

Expand All @@ -528,7 +529,7 @@ That's it! By printing ``form_widget(form)``, each field in the form is
rendered, along with a label and error message (if there is one). While this is
convenient, it's not very flexible (yet). Usually, you'll want to render each
form field individually so you can control how the form looks. You'll learn how
to do that in the ":doc:`/form/rendering`" section.
to do that in the :doc:`form customization </form/form_customization>` article.

Changing a Form's Method and Action
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
9 changes: 5 additions & 4 deletions form/create_custom_field_type.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ shipping options.
Creating a Template for the Field
---------------------------------

Each field type is rendered by a template fragment, which is determined in part by
the class name of your type. For more information, see :ref:`form-customization-form-themes`.
Each field type is rendered by a template fragment whose name is determined in
part by the class name of your type. Read the :ref:`from fragment naming <form-fragment-naming>`
rules for more details.

.. note::

Expand Down Expand Up @@ -147,8 +148,8 @@ link for details), create a ``shipping_widget`` block to handle this:
.. note::

Make sure the correct widget prefix is used. In this example the name should
be ``shipping_widget`` (see :ref:`form-customization-form-themes`).
Further, the main config file should point to the custom form template
be ``shipping_widget`` (see :ref:`form fragment naming <form-fragment-naming>`
rules). Further, the main config file should point to the custom form template
so that it's used when rendering all forms.

When using Twig this is:
Expand Down
2 changes: 1 addition & 1 deletion form/create_form_type_extension.rst
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ Override the File Widget Template Fragment

Each field type is rendered by a template fragment. Those template fragments
can be overridden in order to customize form rendering. For more information,
you can refer to the :ref:`form-customization-form-themes` article.
you can refer to the :ref:`form fragment naming <form-fragment-naming>` rules.

In your extension class, you added a new variable (``image_url``), but
you still need to take advantage of this new variable in your templates.
Expand Down
Loading