Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit467de14

Browse files
ricardodevriesxabbuh
authored andcommitted
#7676 - Flash messages
1 parent01b10f1 commit467de14

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

‎controller.rst‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ and then redirects. The message key (``notice`` in this example) can be anything
407407
you'll use this key to retrieve the message.
408408

409409
In the template of the next page (or even better, in your base layout template),
410-
read any flash messages from the session:
410+
read any flash messages from the session using ``app.flashes()``:
411411

412412
..configuration-block::
413413

@@ -416,17 +416,17 @@ read any flash messages from the session:
416416
{# app/Resources/views/base.html.twig #}
417417

418418
{# you can read and display just one flash message type... #}
419-
{% forflash_message in app.session.flashBag.get('notice') %}
419+
{% formessage in app.flashes('notice') %}
420420
<div class="flash-notice">
421-
{{flash_message }}
421+
{{message }}
422422
</div>
423423
{% endfor %}
424424

425425
{# ...or you can read and display every flash message available #}
426-
{% fortype, flash_messages in app.session.flashBag.all %}
427-
{% forflash_message inflash_messages %}
428-
<divx x-first x-last">type }}">
429-
{{flash_message }}
426+
{% forlabel, messages in app.flashes %}
427+
{% formessage inmessages %}
428+
<divx x-first x-last">label }}">
429+
{{message }}
430430
</div>
431431
{% endfor %}
432432
{% endfor %}
@@ -451,6 +451,10 @@ read any flash messages from the session:
451451
<?php endforeach ?>
452452
<?php endforeach ?>
453453

454+
..versionadded::3.3
455+
The ``app.flashes()`` method was introduced in Symfony 3.3. Prior to version 3.3
456+
you had to use ``app.session.flashBag``.
457+
454458
..note::
455459

456460
It's common to use ``notice``, ``warning`` and ``error`` as the keys of the

‎quick_tour/the_controller.rst‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,12 +331,16 @@ And you can display the flash message in the template like this:
331331

332332
..code-block::html+twig
333333

334-
{% forflashMessage in app.session.flashBag.get('notice') %}
334+
{% formessage in app.flashes('notice') %}
335335
<div class="flash-notice">
336-
{{flashMessage }}
336+
{{message }}
337337
</div>
338338
{% endfor %}
339339

340+
..versionadded::3.3
341+
The ``app.flashes()`` method was introduced in Symfony 3.3. Prior to version 3.3
342+
you had to use ``app.session.flashBag``.
343+
340344
Final Thoughts
341345
--------------
342346

‎session/avoid_session_start.rst‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ that a session is *always* started:
1515

1616
..code-block::html+twig
1717

18-
{% forflashMessage in app.session.flashBag.get('notice') %}
18+
{% formessage in app.flashes('notice') %}
1919
<div class="flash-notice">
20-
{{flashMessage }}
20+
{{message }}
2121
</div>
2222
{% endfor %}
2323

@@ -30,9 +30,13 @@ access the flash messages:
3030
..code-block::html+twig
3131

3232
{% if app.request.hasPreviousSession %}
33-
{% forflashMessage in app.session.flashBag.get('notice') %}
33+
{% formessage in app.flashes('notice') %}
3434
<div class="flash-notice">
35-
{{flashMessage }}
35+
{{message }}
3636
</div>
3737
{% endfor %}
3838
{% endif %}
39+
40+
..versionadded::3.3
41+
The ``app.flashes()`` method was introduced in Symfony 3.3. Prior to version 3.3
42+
you had to use ``app.session.flashBag``.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp