@@ -604,12 +604,13 @@ session.
604
604
Flash Messages
605
605
~~~~~~~~~~~~~~
606
606
607
- You can also store small messages that will be stored on the user's session.
608
- This is useful when processing a form:
609
- you want to redirect and have a special message shown on the *next * page.
610
- These types of messages are called "flash" messages.
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.
611
612
612
- For example, imagine you're processing a form submit ::
613
+ Consider the following form processing example ::
613
614
614
615
use Symfony\Component\HttpFoundation\Request;
615
616
@@ -633,12 +634,12 @@ For example, imagine you're processing a form submit::
633
634
return $this->render(...);
634
635
}
635
636
636
- After processing the request, the controller sets a `` notice `` flash message
637
- in the session and then redirects. The name (``notice ``) isn't significant -
638
- it's just something you invent and reference next .
637
+ 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 .
639
640
640
641
In the template of the next page (or even better, in your base layout template),
641
- the following code will render the ``notice `` message :
642
+ the following code will render the messages stored under the ``notice `` key :
642
643
643
644
.. configuration-block ::
644
645
@@ -660,9 +661,9 @@ the following code will render the ``notice`` message:
660
661
661
662
.. note ::
662
663
663
- By design, flash messages are meant to be processed exactly once. This means
664
- that they vanish from the session automatically when they are retrieved from
665
- the flash bag by calling the `` get() `` method .
664
+ It's common to use `` notice ``, `` warning `` and `` error` as the keys of the
665
+ different types of flash messages, but you can use any key that fits your
666
+ needs .
666
667
667
668
.. tip::
668
669
0 commit comments