Skip to content

Commit

Permalink
minor #863 Fixed the handling of flash messages (javiereguiluz)
Browse files Browse the repository at this point in the history
This PR was merged into the master branch.

Discussion
----------

Fixed the handling of flash messages

Fixes the #859 merge.

Commits
-------

e6349dc Fixed the handling of flash messages
  • Loading branch information
javiereguiluz committed Oct 4, 2018
2 parents 2615325 + e6349dc commit c2f3c59
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions templates/default/_flash_messages.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
A common practice to better distinguish between templates and fragments is to
prefix fragments with an underscore. That's why this template is called
'_flash_messages.html.twig' instead of 'flash_messages.html.twig'
#}

We check if we have session before reading flashes as it otherwise triggers session start:
{#
The request method check is needed to prevent starting the session when looking for "flash messages":
https://symfony.com/doc/current/session/avoid_session_start.html
TIP: With FOSHttpCache you can also adapt this to make it cache safe:
https://foshttpcachebundle.readthedocs.io/en/latest/features/helpers/flash-message.html
#}

{% if app.request.hasPreviousSession %}
{% if app.request.method == 'POST' %}
<div class="messages">
{% for type, messages in app.flashes %}
{% for message in messages %}
Expand Down

0 comments on commit c2f3c59

Please sign in to comment.