0

I'm having trouble showing flash messages with Phalcon PhP. Here is how I register the service:

use Phalcon\Flash\Direct as Flash;
$di->set('flash', function () {
    return new Flash(array(
        'error'   => 'alert alert-danger',
        'success' => 'alert alert-success',
        'notice'  => 'alert alert-info',
        'warning' => 'alert alert-warning'
    ));
});

In my controller I add the flash message like this

$this->flash->success('The carrier was successfully activated');

In my view I try to show like this (volt):

{{ flash.output() }}

My layout has the {{ content() }} tag and I have tried to apply the discussed in this post but it doesn't work anyway.

Can you see what I'm missing here? Thanks for any help!

André Luiz
  • 6,642
  • 9
  • 55
  • 105

1 Answers1

1

Your are using the wrong flash session. Instead of

use Phalcon\Flash\Direct as Flash;

Use

use Phalcon\Flash\Session as Flash;

The documentation says:

  • Flash\Direct will directly outputs the messages passed to the flash.
  • Flash\Session will temporarily store the messages in session, then messages can be printed in the next request
Timothy
  • 2,004
  • 3
  • 23
  • 29