Validation and messages · Question 9 of 12
A backend module without Extbase should show the message "Saved" after saving. How do you create it?
1 answer is correct. Medium
Show answer
Answer
- C Create a FlashMessage with ContextualFeedbackSeverity::OK and enqueue it into the default queue via FlashMessageService::getMessageQueueByIdentifier()
Explanation
addFlashMessage() belongs to the Extbase ActionController. Without Extbase, you get the FlashMessageService via dependency injection, call getMessageQueueByIdentifier() without an argument (default queue core.template.flashMessages) and pass the message with enqueue() or addMessage(). If it should survive a redirect, set storeInSession to true when creating it. If the module works with the ModuleTemplate, $view->addFlashMessage() is shorter and uses the same queue.