FlashMessages ViewHelper <f:flashMessages>
This ViewHelper renders the Flash messages (if there are any) as an unsorted list.

Example for the output of flash messages in an Extbase plugin
Go to the source code of this ViewHelper: FlashMessagesViewHelper.php (GitHub).
Table of contents
Quick start: Simple flash message output
You can use the following tag within any Extbase template:
<f:flashMessages />
It displays the flash messages with a standard bootstrap compatible layout.
Adding and displaying flash messages in Extbase
Within an Extbase controller
(extending
Action
) you
can call method add
to add flash messages to the message queue:
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\Controller;
use Psr\Http\Message\ResponseInterface;
use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
class MyController extends ActionController
{
public function demonstrateFlashMessagesAction(): ResponseInterface
{
$this->addFlashMessage('This is a success message.');
$this->addFlashMessage('This is a warning.', 'Warning Headline', ContextualFeedbackSeverity::WARNING);
return $this->htmlResponse();
}
}
As mentioned above, they will be displayed when a <f:
is displayed within any action
of the same controller:
If you want to display the flash messages in any place outside of the controller
you can use the identifier extbase.
, for example:
Using a specific flash message queue in plain classes
When you use the FlashMessages ViewHelper outside of the Extbase context, supplying the queueIdentifier is mandatory.
When you add a message manually to the queue, you can specify an arbitrary identifier:
// private \TYPO3\CMS\Core\Messaging\FlashMessageService $flashMessageService;
$messageQueue = $this->flashMessageService->getMessageQueueByIdentifier('myQueue');
You can then display messages of only this one queue using the identifier:
<f:flashMessages queueIdentifier="myQueue" />
Output flash messages with a custom layout
Using the argument as
you can receive all flash messages in a variable and then handle the rendering
yourself within the <f:
tag:
<f:flashMessages as="flashMessages">
<dl class="messages">
<f:for each="{flashMessages}" as="flashMessage">
<dt>{flashMessage.code}</dt>
<dd>{flashMessage.message}</dd>
</f:for>
</dl>
</f:flashMessages>
Argument of the FlashMessages ViewHelper
as
-
- Type
- string
The name of the current flashMessage variable for rendering inside
queueIdentifier
-
- Type
- string
Flash-message queue to use