Reputation: 21
I'm using Symfony 2.8.2 and somehow the FlashMessage does not live through a redirect.
$this->addFlash('success', 'Expedition erfolgreich!');
return $this->redirectToRoute('mainmenu_dashboard');
After the redirect there is no flashmessage. I already looked in the session (dumped it) but there is no flash message after the redirect.
Any ideas?
Upvotes: 1
Views: 1739
Reputation: 21
Thank's for your answer!
I discovered the problem somewhere else. I used session_write_close() somewhere else to set the session to not blocking (to be able to cancel a request). This was the reason why session was not writeable at this point anymore!
Upvotes: 0
Reputation: 1769
You'll need to check for, and display, the flashMessage in your twig template for the mainmenu_dashboard
route.
For example:
{% for flashMessage in app.session.flashbag.get('success') %}
<div class="success">{{ flashMessage }}</div>
{% endfor %}
The flash will exist in session, between routes, until they are used.
Upvotes: 1