Skip to content

[Form] Introduce validation events #17229

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

Open
wants to merge 1 commit into
base: 6.2
Choose a base branch
from
Open
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
49 changes: 40 additions & 9 deletions form/events.rst
Original file line number Diff line number Diff line change
@@ -228,6 +228,35 @@ View data Normalized data transformed using a view transformer
subscribes to the ``FormEvents::POST_SUBMIT`` event in order to
automatically validate the denormalized object.

3) Validating the Form (``ValidatorFormEvents::PRE_VALIDATE`` and ``ValidatorFormEvents::POST_VALIDATE``)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Form validation is triggered by the ``FormEvents::POST_SUBMIT`` event of the root form.
Two events are dispatched when Form validation is triggered:
``ValidatorFormEvents::PRE_VALIDATE``, ``ValidatorFormEvents::POST_VALIDATE``.

A) The ``ValidatorFormEvents::PRE_VALIDATE`` Event
..................................................

The ``ValidatorFormEvents::PRE_VALIDATE`` event is dispatched at the beginning of the
Form validation.

.. seealso::

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

B) The ``ValidatorFormEvents::POST_VALIDATE`` Event
...................................................

The ``ValidatorFormEvents::POST_VALIDATE`` event is dispatched after the
the entire form has been validated.

.. seealso::

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

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

@@ -244,15 +273,17 @@ processed.

.. _component-form-event-table:

====================== ============================= ===============
Name ``FormEvents`` Constant Event's Data
====================== ============================= ===============
``form.pre_set_data`` ``FormEvents::PRE_SET_DATA`` Model data
``form.post_set_data`` ``FormEvents::POST_SET_DATA`` Model data
``form.pre_submit`` ``FormEvents::PRE_SUBMIT`` Request data
``form.submit`` ``FormEvents::SUBMIT`` Normalized data
``form.post_submit`` ``FormEvents::POST_SUBMIT`` View data
====================== ============================= ===============
====================== ====================================== ===============
Name ``FormEvents`` Constant Event's Data
====================== ====================================== ===============
``form.pre_set_data`` ``FormEvents::PRE_SET_DATA`` Model data
``form.post_set_data`` ``FormEvents::POST_SET_DATA`` Model data
``form.pre_submit`` ``FormEvents::PRE_SUBMIT`` Request data
``form.submit`` ``FormEvents::SUBMIT`` Normalized data
``form.post_submit`` ``FormEvents::POST_SUBMIT`` View data
``form.pre_validate`` ``ValidatorFormEvents::PRE_VALIDATE`` View data
``form.post_validate`` ``ValidatorFormEvents::POST_VALIDATE`` View data
====================== ====================================== ===============

Event Listeners
~~~~~~~~~~~~~~~