@@ -62,7 +62,6 @@ A) The ``FormEvents::PRE_SET_DATA`` Event
6262The ``FormEvents::PRE_SET_DATA `` event is dispatched at the beginning of the
6363``Form::setData() `` method. It is used to modify the data given during
6464pre-population with
65- :method: `FormEvent::setData() <Symfony\\ Component\\ Form\\ FormEvent::setData> `.
6665The method :method: `Form::setData() <Symfony\\ Component\\ Form\\ Form::setData> `
6766is locked since the event is dispatched from it and will throw an exception
6867if called from a listener.
@@ -274,16 +273,16 @@ method of the ``FormFactory``::
274273
275274 // ...
276275
276+ use Symfony\Component\Form\Event\PreSubmitEvent;
277277 use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
278278 use Symfony\Component\Form\Extension\Core\Type\EmailType;
279279 use Symfony\Component\Form\Extension\Core\Type\TextType;
280- use Symfony\Component\Form\FormEvent;
281280 use Symfony\Component\Form\FormEvents;
282281
283282 $form = $formFactory->createBuilder()
284283 ->add('username', TextType::class)
285284 ->add('showEmail', CheckboxType::class)
286- ->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event): void {
285+ ->addEventListener(FormEvents::PRE_SUBMIT, function (PreSubmitEvent $event): void {
287286 $user = $event->getData();
288287 $form = $event->getForm();
289288
@@ -311,9 +310,9 @@ callback for better readability::
311310 // src/Form/SubscriptionType.php
312311 namespace App\Form;
313312
313+ use Symfony\Component\Form\Event\PreSetDataEvent;
314314 use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
315315 use Symfony\Component\Form\Extension\Core\Type\TextType;
316- use Symfony\Component\Form\FormEvent;
317316 use Symfony\Component\Form\FormEvents;
318317
319318 // ...
@@ -331,7 +330,7 @@ callback for better readability::
331330 ;
332331 }
333332
334- public function onPreSetData(FormEvent $event): void
333+ public function onPreSetData(PreSetDataEvent $event): void
335334 {
336335 // ...
337336 }
@@ -352,8 +351,9 @@ Consider the following example of a form event subscriber::
352351 namespace App\Form\EventListener;
353352
354353 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
354+ use Symfony\Component\Form\Event\PreSetDataEvent;
355+ use Symfony\Component\Form\Event\PreSubmitEvent;
355356 use Symfony\Component\Form\Extension\Core\Type\EmailType;
356- use Symfony\Component\Form\FormEvent;
357357 use Symfony\Component\Form\FormEvents;
358358
359359 class AddEmailFieldListener implements EventSubscriberInterface
@@ -366,7 +366,7 @@ Consider the following example of a form event subscriber::
366366 ];
367367 }
368368
369- public function onPreSetData(FormEvent $event): void
369+ public function onPreSetData(PreSetDataEvent $event): void
370370 {
371371 $user = $event->getData();
372372 $form = $event->getForm();
@@ -378,7 +378,7 @@ Consider the following example of a form event subscriber::
378378 }
379379 }
380380
381- public function onPreSubmit(FormEvent $event): void
381+ public function onPreSubmit(PreSubmitEvent $event): void
382382 {
383383 $user = $event->getData();
384384 $form = $event->getForm();
0 commit comments