2011-05-30 08:19:21 +01:00
|
|
|
<?php
|
2015-03-24 16:36:00 +00:00
|
|
|
|
2011-05-30 08:19:21 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the Symfony package.
|
|
|
|
*
|
|
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Symfony\Component\Form;
|
|
|
|
|
|
|
|
/**
|
2014-11-29 10:11:35 +00:00
|
|
|
* To learn more about how form events work check the documentation
|
2015-05-01 15:06:45 +01:00
|
|
|
* entry at {@link https://symfony.com/doc/any/components/form/form_events.html}.
|
2014-11-29 10:11:35 +00:00
|
|
|
*
|
|
|
|
* To learn how to dynamically modify forms using events check the cookbook
|
2015-05-01 15:06:45 +01:00
|
|
|
* entry at {@link https://symfony.com/doc/any/cookbook/form/dynamic_form_modification.html}.
|
2014-11-29 10:11:35 +00:00
|
|
|
*
|
2012-05-26 08:48:33 +01:00
|
|
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
2011-05-30 08:19:21 +01:00
|
|
|
*/
|
|
|
|
final class FormEvents
|
|
|
|
{
|
2014-10-23 13:21:59 +01:00
|
|
|
/**
|
2014-11-17 13:53:37 +00:00
|
|
|
* 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.
|
|
|
|
*
|
2018-10-18 21:44:28 +01:00
|
|
|
* @Event("Symfony\Component\Form\Event\PreSubmitEvent")
|
2014-10-23 13:21:59 +01:00
|
|
|
*/
|
2017-10-19 17:41:04 +01:00
|
|
|
const PRE_SUBMIT = 'form.pre_submit';
|
2011-05-30 08:19:21 +01:00
|
|
|
|
2014-10-23 13:21:59 +01:00
|
|
|
/**
|
2019-03-12 20:16:42 +00:00
|
|
|
* The SUBMIT event is dispatched after the Form::submit() method
|
|
|
|
* has changed the view data by the request data, or submitted and mapped
|
|
|
|
* the children if the form is compound, and after reverse transformation
|
|
|
|
* to normalized representation.
|
2014-11-17 13:53:37 +00:00
|
|
|
*
|
2019-03-12 20:16:42 +00:00
|
|
|
* It's also dispatched just before the Form::submit() method transforms back
|
|
|
|
* the normalized data to the model and view data.
|
|
|
|
*
|
|
|
|
* So at this stage children of compound forms are submitted and synchronized, unless
|
|
|
|
* their transformation failed, but a parent would still be at the PRE_SUBMIT level.
|
|
|
|
*
|
|
|
|
* Since the current form is not synchronized yet, it is still possible to add and
|
|
|
|
* remove fields.
|
2014-11-17 13:53:37 +00:00
|
|
|
*
|
2018-10-18 21:44:28 +01:00
|
|
|
* @Event("Symfony\Component\Form\Event\SubmitEvent")
|
2014-10-23 13:21:59 +01:00
|
|
|
*/
|
2017-10-19 17:41:04 +01:00
|
|
|
const SUBMIT = 'form.submit';
|
2012-05-23 19:58:42 +01:00
|
|
|
|
2014-10-23 13:21:59 +01:00
|
|
|
/**
|
2019-03-12 20:16:42 +00:00
|
|
|
* The FormEvents::POST_SUBMIT event is dispatched at the very end of the Form::submit().
|
|
|
|
*
|
|
|
|
* It this stage the model and view data may have been denormalized. Otherwise the form
|
|
|
|
* is desynchronized because transformation failed during submission.
|
2014-11-17 13:53:37 +00:00
|
|
|
*
|
|
|
|
* It can be used to fetch data after denormalization.
|
|
|
|
*
|
2019-03-12 20:16:42 +00:00
|
|
|
* The event attaches the current view data. To know whether this is the renormalized data
|
|
|
|
* or the invalid request data, call Form::isSynchronized() first.
|
|
|
|
*
|
2018-10-18 21:44:28 +01:00
|
|
|
* @Event("Symfony\Component\Form\Event\PostSubmitEvent")
|
2014-10-23 13:21:59 +01:00
|
|
|
*/
|
2017-10-19 17:41:04 +01:00
|
|
|
const POST_SUBMIT = 'form.post_submit';
|
2011-05-30 08:19:21 +01:00
|
|
|
|
2014-10-23 13:21:59 +01:00
|
|
|
/**
|
2014-11-17 13:53:37 +00:00
|
|
|
* 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;
|
2019-03-12 20:16:42 +00:00
|
|
|
* - Keep synchronized the form depending on the data (adding or removing fields dynamically).
|
2014-11-17 13:53:37 +00:00
|
|
|
*
|
2018-10-18 21:44:28 +01:00
|
|
|
* @Event("Symfony\Component\Form\Event\PreSetDataEvent")
|
2014-10-23 13:21:59 +01:00
|
|
|
*/
|
2011-05-30 08:19:21 +01:00
|
|
|
const PRE_SET_DATA = 'form.pre_set_data';
|
|
|
|
|
2014-10-23 13:21:59 +01:00
|
|
|
/**
|
2014-11-17 13:53:37 +00:00
|
|
|
* The FormEvents::POST_SET_DATA event is dispatched at the end of the Form::setData() method.
|
|
|
|
*
|
2019-03-12 20:16:42 +00:00
|
|
|
* This event can be used to modify the form depending on the final state of the underlying data
|
|
|
|
* accessible in every representation: model, normalized and view.
|
2014-11-17 13:53:37 +00:00
|
|
|
*
|
2018-10-18 21:44:28 +01:00
|
|
|
* @Event("Symfony\Component\Form\Event\PostSetDataEvent")
|
2014-10-23 13:21:59 +01:00
|
|
|
*/
|
2011-05-30 08:19:21 +01:00
|
|
|
const POST_SET_DATA = 'form.post_set_data';
|
|
|
|
|
2012-05-23 19:58:42 +01:00
|
|
|
private function __construct()
|
|
|
|
{
|
|
|
|
}
|
2011-05-30 08:19:21 +01:00
|
|
|
}
|