It's possible to add some events to every form submission.
The FORM_TYPE_OPTIONS
event is dispatched after the form builder options has been defined.
It contains the field name, type and the defined options. You're able to modify the options only.
@see \FormBuilderBundle\Event\Form\FormTypeOptionsEvent
Example
<?php
use FormBuilderBundle\FormBuilderEvents;
[
FormBuilderEvents::FORM_TYPE_OPTIONS => 'formTypeOptions'
];
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'
];
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'
];
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'
];
The FORM_SUBMIT_SUCCESS
event occurs when a frontend form submission was successful.
Example
<?php
use FormBuilderBundle\FormBuilderEvents;
[
FormBuilderEvents::FORM_SUBMIT_SUCCESS => 'formSubmitSuccess'
];
This Event has been marked as deprecated since version 3.3.
Use the OUTPUT_WORKFLOW_GUARD_SUBJECT_PRE_DISPATCH
event instead.
The FORM_MAIL_PRE_SUBMIT
event occurs before sending an email.
Example
<?php
use FormBuilderBundle\FormBuilderEvents;
[
FormBuilderEvents::FORM_MAIL_PRE_SUBMIT => 'formMailPreSubmit'
];
Read more about this event here.
Example
<?php
use FormBuilderBundle\FormBuilderEvents;
[
FormBuilderEvents::OUTPUT_WORKFLOW_GUARD_SUBJECT_PRE_DISPATCH => 'checkSubject'
];