From 244439ef9c71386ce721d74ba1354b20f1839096 Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Tue, 16 Nov 2010 20:57:04 +0100 Subject: [PATCH] Adapted the form templating documentation to the refactoring --- guides/forms/index.rst | 1 - guides/forms/twig.rst | 366 ---------------------------- guides/forms/view.rst | 536 ++++++++++++++++++++++++++++------------- 3 files changed, 365 insertions(+), 538 deletions(-) delete mode 100644 guides/forms/twig.rst diff --git a/guides/forms/index.rst b/guides/forms/index.rst index 2b608d8a05d..b4bc46c9753 100644 --- a/guides/forms/index.rst +++ b/guides/forms/index.rst @@ -6,4 +6,3 @@ Symfony2 Forms overview view - twig diff --git a/guides/forms/twig.rst b/guides/forms/twig.rst deleted file mode 100644 index 40cccb6d877..00000000000 --- a/guides/forms/twig.rst +++ /dev/null @@ -1,366 +0,0 @@ -.. index:: - pair: Forms; Twig - -Forms in Twig Templates -======================= - -A Symfony2 :doc:`Form ` is made of fields. Fields -describe the form semantic, not its end-user representation; it means that a -form is not necessarily tied to HTML. Instead, it is the responsibility of the -web designer to display each form field the way he wants. So, displaying a -Symfony2 form in a template can easily be done manually. But, Twig eases form -integration and customization by providing a set of filters that can be applied -on the form and field instances. - -Displaying a Form "manually" ----------------------------- - -Before diving into the Twig filters and how they help you display form easily, -securely, and fast, you must know that nothing special happens under the hood. -You can use any HTML you want to display a Symfony2 form: - -.. code-block:: html - -
- - - -
- -If there is a validation error, you should display it and fill the fields with -the submitted values to make it easier to fix the problems fast. Just use the -form dedicated methods: - -.. code-block:: jinja - -
- - - - -
- -The Twig filters help you to keep your template short, make your form layout -easily customizable, support internationalization, CSRF protection, file -upload, and more out of the box. The following sections tells you everything -about them. - -Displaying a Form ------------------ - -As the global structure of a form (the form tag, the submit button, ...) is -not defined by the form instance, you are free to use the HTML code you want. -A simple form template reads as follows: - -.. code-block:: html - -
- - - -
- -Besides the global form structure, you need a way to display global errors and -hidden fields; that's the job of the ``render_errors`` and ``render_hidden`` -filters respectively: - -.. code-block:: jinja - -
- {{ form|render_errors }} - - - - {{ form|render_hidden }} - -
- -.. note:: - By default, the ``render_errors`` generates a ``