Skip to content

Commit c2f3c59

Browse files
committed
minor #863 Fixed the handling of flash messages (javiereguiluz)
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
2 parents 2615325 + e6349dc commit c2f3c59

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

templates/default/_flash_messages.html.twig

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@
55
A common practice to better distinguish between templates and fragments is to
66
prefix fragments with an underscore. That's why this template is called
77
'_flash_messages.html.twig' instead of 'flash_messages.html.twig'
8+
#}
89

9-
We check if we have session before reading flashes as it otherwise triggers session start:
10+
{#
11+
The request method check is needed to prevent starting the session when looking for "flash messages":
1012
https://symfony.com/doc/current/session/avoid_session_start.html
1113
1214
TIP: With FOSHttpCache you can also adapt this to make it cache safe:
1315
https://foshttpcachebundle.readthedocs.io/en/latest/features/helpers/flash-message.html
1416
#}
15-
16-
{% if app.request.hasPreviousSession %}
17+
{% if app.request.method == 'POST' %}
1718
<div class="messages">
1819
{% for type, messages in app.flashes %}
1920
{% for message in messages %}

0 commit comments

Comments
 (0)