PUGXMultiUserBundle icon indicating copy to clipboard operation
PUGXMultiUserBundle copied to clipboard

Flash messages after redirection

Open pjam opened this issue 9 years ago • 2 comments

Hi.

In my app, after a user changes his password, I redirect him to his profile form page. Doing so, the flash message with the password change success is getting eaten in the way, as it does not show.

pjam avatar Oct 14 '16 22:10 pjam

How do you perform the redirect?

garak avatar Oct 15 '16 09:10 garak

I use a listener for the CHANGE_PASSWORD_SUCCESS event setting the response with a RedirectResponse for the profile route. I found out that the flashes get lost after $result = $this->controller->editAction($this->getRequest()); in the edit method of the Profile Manager.

My workaround is saving the existing flashes before that call: $flashes = $this->getRequest()->getSession()->getFlashBag()->all();

and then setting them back afterwards with $this->getRequest()->getSession()->getFlashBag()->setAll($flashes);

pjam avatar Oct 16 '16 14:10 pjam