W3cubDocs

/Symfony 4.1

FormEvents

class FormEvents

To learn more about how form events work check the documentation entry at {@link https://symfony.com/doc/any/components/form/form_events.html}.

To learn how to dynamically modify forms using events check the cookbook entry at {@link https://symfony.com/doc/any/cookbook/form/dynamic_form_modification.html}.

Constants

PRE_SUBMIT

The PRE_SUBMIT event is dispatched at the beginning of the Form::submit() method.

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.

SUBMIT

The SUBMIT event is dispatched just before the Form::submit() method 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.

POST_SUBMIT

The FormEvents::POST_SUBMIT event is dispatched after the Form::submit() once the model and view data have been denormalized.

It can be used to fetch data after denormalization.

PRE_SET_DATA

The FormEvents::PRE_SET_DATA event is dispatched at the beginning of the Form::setData() method.

It can be used to: - Modify the data given during pre-population; - Modify a form depending on the pre-populated data (adding or removing fields dynamically).

POST_SET_DATA

The FormEvents::POST_SET_DATA event is dispatched at the end of the Form::setData() method.

This event is mostly here for reading data after having pre-populated the form.

© 2004–2017 Fabien Potencier
Licensed under the MIT License.
https://api.symfony.com/4.1/Symfony/Component/Form/FormEvents.html