Documentations

Custom flash

Of course you can customize the flash messages, at the display level, the messages are displayed in the src/View/Partal/_messages.html.twig file.

By default, the display looks like this:

‹div class="{{ message.color }}"›{{ message.message }}‹/div›

If you have bootstrap integrated into your layout, you could use a display that looks like this:

‹div class="alert alert-dismissible alert-{{ message.color }}"› ‹button type="button" class="btn-close" data-bs-dismiss="alert"›‹/button› {{ message.message }} ‹/div›

and in your flash message creation, you just use the color, like in this example:

$this->addFlash("success", "all went well");