Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I just tested the following in a Controller:</p> <pre><code>$this-&gt;flashMessenger()-&gt;addSuccessMessage('test'); if ($this-&gt;flashMessenger()-&gt;hasSuccessMessages()) { print_r($this-&gt;flashMessenger()-&gt;getSuccessMessages()); } </code></pre> <p>This resulted in <code>Array ( [0] =&gt; test )</code></p> <p>Based on your question it appears you have not yet called on <code>getSuccessMessages()</code></p> <p>To get the messages into your ViewModel you could do something like this:</p> <pre><code>$viewModel = new ViewModel(); $viewModel-&gt;setVariable('messages', ($this-&gt;flashMessenger()-&gt;hasSuccessMessages()) ? $this-&gt;flashMessenger()-&gt;getSuccessMessages() : null); </code></pre> <p>And in your View you could do this:</p> <pre><code>if (!is_null($this-&gt;messages)) { foreach ($this-&gt;messages as $message) { echo $message . "\n"; } } </code></pre> <p>Try reloading the page a few times to ensure that the message is visible. I personally use the EventManager (in my Controller) to check and handle messages stored in the flashMessenger(). For example:</p> <pre><code>public function setEventManager(EventManagerInterface $events) { parent::setEventManager($events); $events-&gt;attach('dispatch', function () { $this-&gt;getServiceLocator()-&gt;get('translator')-&gt;setLocale('en'); if ($this-&gt;flashMessenger()-&gt;hasMessages()) { $this-&gt;Flash()-&gt;Display($this-&gt;flashMessenger()-&gt;getMessages()); // Custom Controller Plugin } }, 100); } </code></pre> <p>Hope this helps you out!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload