Skip to content

Fixes for Form Component chapter #2997

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

Merged
merged 1 commit into from
Oct 7, 2013
Merged
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
33 changes: 18 additions & 15 deletions components/form/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ be from a normal form post or from an API.
Installation
------------

You can install the component in many different ways:
You can install the component in 2 different ways:

* Use the official Git repository (https://github.com/symfony/Form);
* Install it via Composer (``symfony/form`` on `Packagist`_).
* :doc:`Install it via Composer </components/using_components>` (``symfony/form`` on `Packagist`_).

Configuration
-------------
Expand Down Expand Up @@ -51,7 +51,8 @@ support for very important features:
messages for submitted data.

The Symfony2 Form component relies on other libraries to solve these problems.
Most of the time you will use Twig and the Symfony :doc:`HttpFoundation</components/http_foundation/introduction>`,
Most of the time you will use Twig and the Symfony
:doc:`HttpFoundation </components/http_foundation/introduction>`,
Translation and Validator components, but you can replace any of these with
a different library of your choice.

Expand All @@ -65,10 +66,12 @@ factory.
Request Handling
~~~~~~~~~~~~~~~~

To process form data, you'll need to grab information off of the request (typically
``$_POST`` data) and pass the array of submitted data to :method:`Symfony\\Component\\Form\\Form::bind`.
The Form component optionally integrates with Symfony's :doc:`HttpFoundation</components/http_foundation/introduction>`
component to make this even easier.
To process form data, you'll need to grab information off of the request
(typically ``$_POST`` data) and pass the array of submitted data to
:method:`Symfony\\Component\\Form\\Form::bind`. The Form component optionally
integrates with Symfony's
:doc:`HttpFoundation </components/http_foundation/introduction>` component to
make this even easier.

To integrate the HttpFoundation component, add the
:class:`Symfony\\Component\\Form\\Extension\\HttpFoundation\HttpFoundationExtension`
Expand Down Expand Up @@ -155,7 +158,7 @@ line to your ``composer.json`` file:
}
}

The TwigBridge integration provides you with several :doc:`Twig Functions</reference/forms/twig_reference>`
The TwigBridge integration provides you with several :doc:`Twig Functions </reference/forms/twig_reference>`
that help you render each the HTML widget, label and error 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 @@ -193,7 +196,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<cookbook-form-customization-form-themes>`
where you define your :ref:`form themes <cookbook-form-customization-form-themes>`
(i.e. resources/files that define form HTML markup).

For general details on rendering forms, see :doc:`/cookbook/form/form_customization`.
Expand All @@ -219,7 +222,7 @@ with Symfony's ``Translation`` component, or add the 2 Twig filters yourself,
via your own Twig extension.

To use the built-in integration, be sure that your project has Symfony's
``Translation`` and :doc:`Config</components/config/introduction>` components
``Translation`` and :doc:`Config </components/config/introduction>` components
installed. If you're using Composer, you could get the latest 2.1 version
of each of these by adding the following to your ``composer.json`` file:

Expand Down Expand Up @@ -404,10 +407,10 @@ is created from the form factory.
As you can see, creating a form is like writing a recipe: you call ``add``
for each new field you want to create. The first argument to ``add`` is the
name of your field, and the second is the field "type". The Form component
comes with a lot of :doc:`built-in types</reference/forms/types>`.
comes with a lot of :doc:`built-in types </reference/forms/types>`.

Now that you've built your form, learn how to :ref:`render<component-form-intro-rendering-form>`
it and :ref:`process the form submission<component-form-intro-handling-submission>`.
Now that you've built your form, learn how to :ref:`render <component-form-intro-rendering-form>`
it and :ref:`process the form submission <component-form-intro-handling-submission>`.

Setting Default Values
~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -443,7 +446,7 @@ builder:
.. tip::

In this example, the default data is an array. Later, when you use the
:ref:`data_class<book-forms-data-class>` option to bind data directly
:ref:`data_class <book-forms-data-class>` option to bind data directly
to objects, your default data will be an instance of that object.

.. _component-form-intro-rendering-form:
Expand Down Expand Up @@ -618,4 +621,4 @@ and the errors will display next to the fields on error.

.. _Packagist: https://packagist.org/packages/symfony/form
.. _Twig: http://twig.sensiolabs.org
.. _`Twig Configuration`: http://twig.sensiolabs.org/doc/intro.html
.. _`Twig Configuration`: http://twig.sensiolabs.org/doc/intro.html