8000 [Form] Add doc for FormEvents · symfony/symfony@656d45f · GitHub
[go: up one dir, main page]

Skip to content

Commit 656d45f

Browse files
committed
[Form] Add doc for FormEvents
1 parent 8d18c98 commit 656d45f

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/Symfony/Component/Form/FormEvents.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,57 @@
1616
final class FormEvents
1717
{
1818
/**
19+
* The PRE_SUBMIT event is dispatched at the beginning of the Form::submit() method.
20+
*
21+
* It can be used to:
22+
* - Change data from the request, before submitting the data to the form.
23+
* - Add or remove form fields, before submitting the data to the form.
24+
* The event listener method receives a Symfony\Component\Form\FormEvent instance.
25+
*
1926
* @Event
2027
*/
2128
const PRE_SUBMIT = 'form.pre_bind';
2229

2330
/**
31+
* The SUBMIT event is dispatched just before the Form::submit() method
32+
* transforms back the normalized data to the model and view data.
33+
*
34+
* It can be used to change data from the normalized representation of the data.
35+
* The event listener method receives a Symfony\Component\Form\FormEvent instance.
36+
*
2437
* @Event
2538
*/
2639
const SUBMIT = 'form.bind';
2740

2841
/**
42+
* The FormEvents::POST_SUBMIT event is dispatched after the Form::submit()
43+
* once the model and view data have been denormalized.
44+
*
45+
* It can be used to fetch data after denormalization.
46+
* The event listener method receives a Symfony\Component\Form\FormEvent instance.
47+
*
2948
* @Event
3049
*/
3150
const POST_SUBMIT = 'form.post_bind';
3251

3352
/**
53+
* The FormEvents::PRE_SET_DATA event is dispatched at the beginning of the Form::setData() method.
54+
*
55+
* It can be used to:
56+
* - Modify the data given during pre-population;
57+
* - Modify a form depending on the pre-populated data (adding or removing fields dynamically).
58+
* The event listener method receives a Symfony\Component\Form\FormEvent instance.
59+
*
3460
* @Event
3561
*/
3662
const PRE_SET_DATA = 'form.pre_set_data';
3763

3864
/**
65+
* The FormEvents::POST_SET_DATA event is dispatched at the end of the Form::setData() method.
66+
*
67+
* This event is mostly here for reading data after having pre-populated the form.
68+
* The event listener method receives a Symfony\Component\Form\FormEvent instance.
69+
*
3970
* @Event
4071
*/
4172
const POST_SET_DATA = 'form.post_set_data';

0 commit comments

Comments
 (0)
0