We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

FlashDirect Not working

Hi,

I try to use flash messages and it doesn't work.

In services I have this:

// Register the flash service with custom CSS classes $di->set('flash', function () {

$flash = new FlashDirect(
    array(
        'error'   => 'alert alert-danger',
        'success' => 'alert alert-success',
        'notice'  => 'alert alert-info',
        'warning' => 'alert alert-warning'
    )
);

return $flash;

});

and in controller I have this:

$this->flash->error("Please enter a User with more than 4 characters");

and in view I have this:

<?php echo $this->flash->output(); ?>

It's something wrong here? I am new with Phalcon.

Thanks!



5.7k
Accepted
answer

Ah, I find the solution:

For FlashDirect you will need to use on View: echo $this->getContent(); For SessionFlash: $this->flashSession->output();