@@ -605,12 +605,11 @@ Flash Messages
605
605
~~~~~~~~~~~~~~
606
606
607
607
You can also store special messages, called "flash" messages, on the user's
608
- session. By design, flash messages are meant to be processed exactly once. This
609
- means that they vanish from the session automatically as soon as they are
610
- retrieved. This feature makes "flash" messages particularly suited for storing
611
- user notifications.
608
+ session. By design, flash messages are meant to be used exactly once: they vanish
609
+ from the session automatically as soon as you retrieve them. This feature makes
610
+ "flash" messages particularly great for storing user notifications.
612
611
613
- Consider the following form processing example ::
612
+ For example, imagine you're processing a form submission ::
614
613
615
614
use Symfony\Component\HttpFoundation\Request;
616
615
@@ -635,19 +634,19 @@ Consider the following form processing example::
635
634
}
636
635
637
636
After processing the request, the controller sets a flash message in the session
638
- and then redirects. The message key (``notice `` in this example) can be freely
639
- chosen and is used to retrieve the message content .
637
+ and then redirects. The message key (``notice `` in this example) can be anything:
638
+ you'll use this key to retrieve the message.
640
639
641
640
In the template of the next page (or even better, in your base layout template),
642
- the following code will render the messages stored under the `` notice `` key :
641
+ read any flash messages from the session: :
643
642
644
643
.. configuration-block ::
645
644
646
645
.. code-block :: html+jinja
647
646
648
- {% for flashMessage in app.session.flashbag.get('notice') %}
647
+ {% for flash_message in app.session.flashbag.get('notice') %}
649
648
<div class="flash-notice">
650
- {{ flashMessage }}
649
+ {{ flash_message }}
651
650
</div>
652
651
{% endfor %}
653
652
0 commit comments