Skip to content

Commit

Permalink
minor #5241 [Components][Form] apply some fixes to the Form events ch…
Browse files Browse the repository at this point in the history
…apter (xabbuh)

This PR was merged into the 2.3 branch.

Discussion
----------

[Components][Form] apply some fixes to the Form events chapter

| Q             | A
| ------------- | ---
| Doc fix?      | yes
| New docs?     | no
| Applies to    | all
| Fixed tickets |

* remove serial commas
* replace wrong event constant
* replace reference to form events overview that did not provide any
  context with a more meaningful `seealso` section

Commits
-------

d9f7e4e apply some fixes to the Form events chapter
  • Loading branch information
weaverryan committed May 23, 2015
2 parents cbb7ea1 + d9f7e4e commit ce7eb04
Showing 1 changed file with 30 additions and 15 deletions.
45 changes: 30 additions & 15 deletions components/form/form_events.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ The ``FormEvents::PRE_SET_DATA`` event is dispatched at the beginning of the
* Modify the data given during pre-population;
* Modify a form depending on the pre-populated data (adding or removing fields dynamically).

:ref:`Form Events Information Table<component-form-event-table>`

=============== ========
Data Type Value
=============== ========
Expand All @@ -70,6 +68,11 @@ Normalized data ``null``
View data ``null``
=============== ========

.. seealso::

See all form events at a glance in the
:ref:`Form Events Information Table <component-form-event-table>`.

.. caution::

During ``FormEvents::PRE_SET_DATA``,
Expand All @@ -95,8 +98,6 @@ The ``FormEvents::POST_SET_DATA`` event is dispatched at the end of the
method. This event is mostly here for reading data after having pre-populated
the form.

:ref:`Form Events Information Table<component-form-event-table>`

=============== ====================================================
Data Type Value
=============== ====================================================
Expand All @@ -105,6 +106,11 @@ Normalized data Model data transformed using a model transformer
View data Normalized data transformed using a view transformer
=============== ====================================================

.. seealso::

See all form events at a glance in the
:ref:`Form Events Information Table <component-form-event-table>`.

.. sidebar:: ``FormEvents::POST_SET_DATA`` in the Form component

The ``Symfony\Component\Form\Extension\DataCollector\EventListener\DataCollectorListener``
Expand Down Expand Up @@ -135,8 +141,6 @@ It can be used to:
* Change data from the request, before submitting the data to the form;
* Add or remove form fields, before submitting the data to the form.

:ref:`Form Events Information Table<component-form-event-table>`

=============== ========================================
Data Type Value
=============== ========================================
Expand All @@ -145,6 +149,11 @@ Normalized data Same as in ``FormEvents::POST_SET_DATA``
View data Same as in ``FormEvents::POST_SET_DATA``
=============== ========================================

.. seealso::

See all form events at a glance in the
:ref:`Form Events Information Table <component-form-event-table>`.

.. sidebar:: ``FormEvents::PRE_SUBMIT`` in the Form component

The ``Symfony\Component\Form\Extension\Core\EventListener\TrimListener``
Expand All @@ -163,8 +172,6 @@ transforms back the normalized data to the model and view data.

It can be used to change data from the normalized representation of the data.

:ref:`Form Events Information Table<component-form-event-table>`

=============== ===================================================================================
Data Type Value
=============== ===================================================================================
Expand All @@ -173,6 +180,11 @@ Normalized data Data from the request reverse-transformed from the request usin
View data Same as in ``FormEvents::POST_SET_DATA``
=============== ===================================================================================

.. seealso::

See all form events at a glance in the
:ref:`Form Events Information Table <component-form-event-table>`.

.. caution::

At this point, you cannot add or remove fields to the form.
Expand All @@ -193,16 +205,19 @@ model and view data have been denormalized.

It can be used to fetch data after denormalization.

:ref:`Form Events Information Table<component-form-event-table>`

=============== =============================================================
Data Type Value
=============== =============================================================
Model data Normalized data reverse-transformed using a model transformer
Normalized data Same as in ``FormEvents::POST_SUBMIT``
Normalized data Same as in ``FormEvents::SUBMIT``
View data Normalized data transformed using a view transformer
=============== =============================================================

.. seealso::

See all form events at a glance in the
:ref:`Form Events Information Table <component-form-event-table>`.

.. caution::

At this point, you cannot add or remove fields to the form.
Expand All @@ -214,21 +229,21 @@ View data Normalized data transformed using a view transformer
information about the forms.
The ``Symfony\Component\Form\Extension\Validator\EventListener\ValidationListener``
subscribes to the ``FormEvents::POST_SUBMIT`` event in order to
automatically validate the denormalized object, and update the normalized
as well as the view's representations.
automatically validate the denormalized object and to update the normalized
representation as well as the view representations.

Registering Event Listeners or Event Subscribers
------------------------------------------------

In order to be able to use Form events, you need to create an event listener
or an event subscriber, and register it to an event.
or an event subscriber and register it to an event.

The name of each of the "form" events is defined as a constant on the
:class:`Symfony\\Component\\Form\\FormEvents` class.
Additionally, each event callback (listener or subscriber method) is passed a
single argument, which is an instance of
:class:`Symfony\\Component\\Form\\FormEvent`. The event object contains a
reference to the current state of the form, and the current data being
reference to the current state of the form and the current data being
processed.

.. _component-form-event-table:
Expand Down

0 comments on commit ce7eb04

Please sign in to comment.