Skip to content

Commit f9f0ed1

Browse files
committed
Merge pull request #1990 from johnkary/fixDeprecatedFormEvents
Remove reference to deprecated DataEvent and FilterDataEvent
2 parents 5bbc322 + 8e9d04f commit f9f0ed1

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

cookbook/form/dynamic_form_generation.rst

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ might look like the following::
9191
// src/Acme/DemoBundle/Form/EventListener/AddNameFieldSubscriber.php
9292
namespace Acme\DemoBundle\Form\EventListener;
9393

94-
use Symfony\Component\Form\Event\DataEvent;
94+
use Symfony\Component\Form\FormEvent;
95+
use Symfony\Component\Form\FormEvents;
9596
use Symfony\Component\Form\FormFactoryInterface;
9697
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
97-
use Symfony\Component\Form\FormEvents;
9898

9999
class AddNameFieldSubscriber implements EventSubscriberInterface
100100
{
@@ -145,20 +145,16 @@ The ``FormEvents::PRE_SET_DATA`` line actually resolves to the string ``form.pre
145145
The `FormEvents class`_ serves an organizational purpose. It is a centralized location
146146
in which you can find all of the various form events available.
147147

148-
While this example could have used the ``form.set_data`` event or even the ``form.post_set_data``
149-
events just as effectively, by using ``form.pre_set_data`` you guarantee that
148+
While this example could have used the ``form.post_set_data``
149+
event just as effectively, by using ``form.pre_set_data`` you guarantee that
150150
the data being retrieved from the ``Event`` object has in no way been modified
151-
by any other subscribers or listeners. This is because ``form.pre_set_data``
152-
passes a `DataEvent`_ object instead of the `FilterDataEvent`_ object passed
153-
by the ``form.set_data`` event. `DataEvent`_, unlike its child `FilterDataEvent`_,
154-
lacks a setData() method.
151+
by any other subscribers or listeners because ``form.pre_set_data`` is the
152+
first form event dispatched.
155153

156154
.. note::
157155

158156
You may view the full list of form events via the `FormEvents class`_,
159157
found in the form bundle.
160158

161-
.. _`DataEvent`: https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Form/Event/DataEvent.php
162159
.. _`FormEvents class`: https://github.com/symfony/Form/blob/master/FormEvents.php
163160
.. _`Form class`: https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Form/Form.php
164-
.. _`FilterDataEvent`: https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Form/Event/FilterDataEvent.php

0 commit comments

Comments
 (0)