M
M
Maxim Lagoysky2019-05-13 16:21:44
symfony
Maxim Lagoysky, 2019-05-13 16:21:44

Why do the values ​​in $this->getUser() change after $form->handleRequest($request)??

There was a question, if you create a form for editing a user and edit yourself in this form, then after

$form->handleRequest($request);
dd($this->getUser());

in the dump, I see that getUser() has already changed, can this be avoided somehow? This is important to me, because I'm still waiting for the old data in the user object.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2019-05-13
@lagoy

Because submit is being executed
1. Submit manually:
Calling Form::submit() manually
2. or use the PRE_SUBMIT event

The FormEvents::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.
https://symfony.com/doc/3.4/form/events.html#a-the...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question