I am transitioning from Symfony 2.0 to Symfony 2.1.
I have the following simple code on my controller:
public function createEntidadeAction() {
$this->get('session')->getFlashBag()->set('error', 'message');
return $this->redirect($this->generateUrl('EntidadeBundle_index'));
}
If I generate an error (for example, skipping an unsuccessful route), I will check the profiler that there is a flash message there.
However, if I allow redirecting to success, the error message will disappear and nothing will be displayed. I am using the following Twig pattern:
{% for flashMessage in app.session.flashbag.get('error') %}
<div class="flash-notice">
{{ flashMessage }}
</div>
{% endfor %}
I can’t figure it out. What am I missing? Pop-up messages should last after the first redirect, no?
source
share