0
votes

TYPO3 8.7

In my controller I've included everything I can think of:

use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Messaging\AbstractMessage;
use TYPO3\CMS\Core\Messaging\FlashMessageService;

... And following the documentation at https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/FlashMessages/Index.html I have done the following in the action (note: I have tried both AbsractMessage and FlashMessage, same result):

$locationName = $location->getName();
$messageBody = "$locationName has been successfully deleted";
$messageTitle = 'Location Deleted';

$this->addFlashMessage(
   $messageBody,
   $messageTitle,
   $severity = \TYPO3\CMS\Core\Messaging\AbstractMessage::OK,
   $storeInSession = TRUE
);

... but all I get for output is:


Location Deleted

flashtest has been successfully deleted


... but I should be getting a nice green box with styled fonts. What am I missing? TIA!!!

2
Are you doing this in the backend or frontend? Can you give us the final HTML output?Thomas Löffler

2 Answers

1
votes

It would be easier if you posted the HTML that is output.

I guess you are missing CSS for the used classes.

0
votes

Bwa-HA! I am using 's in my view, so I had to put inside the section, not on its own!!!! Full solution to implement Flash Messages follows ...

Controller:

(no need for any of the "use \TYPO3\CMS\Core..." stuff)

$this->addFlashMessage(
  $messageBody,
  $messageTitle, // optional
  $severity = \TYPO3\CMS\Core\Messaging\FlashMessage::OK, // default OK
  $storeInSession = TRUE // optional
);

View:

<f:section name="content">
  <f:flashMessages />
  ....