Answer the question
In order to leave comments, you need to log in
How to return data from form event?
Good afternoon everyone, tell me such a moment in the forms, I can’t figure it out myself. I have a select on the form, when I select anything there, ajax happens and the PRE_SET_DATA event occurs. Here the first moment arises, in the documentation the data is obtained as follows
$builder->addEventListener(
FormEvents::PRE_SET_DATA,
function (FormEvent $event) {
$form = $event->getForm();
$data = $event->getData();
.....
Answer the question
In order to leave comments, you need to log in
https://symfony.com/doc/current/form/dynamic_form_...
https://github.com/symfony/symfony/blob/4.3/src/Sy...
Model data is passed to the event. What makes you think that there is nothing there?
Or you forms are used without data_class?
If you need to use values from a request in an event, create an EventListener and use this to inject request - https://symfony.com/doc/current/service_container/...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question