Skip to content

Latest commit

 

History

History
87 lines (63 loc) · 2.04 KB

70_Events.md

File metadata and controls

87 lines (63 loc) · 2.04 KB

Events

It's possible to add some events to every form submission.

Pre Set Data Event

The FORM_PRE_SET_DATA event is dispatched at the beginning of the Form::setData() method. It contains the form event and also some form builder settings.

@see \FormBuilderBundle\Event\Form\PreSetDataEvent https://symfony.com/doc/current/form/events.html#a-the-formevents-pre-set-data-event

Example

<?php

use FormBuilderBundle\FormBuilderEvents;

[
    FormBuilderEvents::FORM_PRE_SET_DATA => 'formPreSetData'
];

Post Set Data Event

The FORM_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. It contains the form event and also some form builder settings.

@see \FormBuilderBundle\Event\Form\PostSetDataEvent http://symfony.com/doc/current/form/events.html#b-the-formevents-post-set-data-event

Example

<?php

use FormBuilderBundle\FormBuilderEvents;

[
    FormBuilderEvents::FORM_POST_SET_DATA => 'formPostSetData'
];

Pre Submit Event

The FORM_PRE_SUBMIT 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. It contains the form event and also some form builder settings.

@see \FormBuilderBundle\Event\Form\PreSubmitEvent https://symfony.com/doc/current/form/events.html#a-the-formevents-pre-submit-event

Example

<?php

use FormBuilderBundle\FormBuilderEvents;

[
    FormBuilderEvents::FORM_PRE_SUBMIT => 'formPreSubmitEvent'
];

Submit Success

The FORM_SUBMIT_SUCCESS event occurs when a frontend form submission was successful.

Example

<?php

use FormBuilderBundle\FormBuilderEvents;

[
    FormBuilderEvents::FORM_SUBMIT_SUCCESS => 'formSubmitSuccess'
];

Mail Pre Submit

The FORM_MAIL_PRE_SUBMIT event occurs before sending an email.

Example

<?php

use FormBuilderBundle\FormBuilderEvents;

[
    FormBuilderEvents::FORM_MAIL_PRE_SUBMIT => 'formMailPreSubmit'
];