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

Flash css classes not working for me

Hello,

I cannot manage to get the Flash component to use the css classes I send it in constructor

in my boostrap file I use the regular

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

in controller :

$this->flash->success('Welcome') 

And in my main view:

echo $this->flashSession->output();

but the generated html still use successMessage as the css class.

Am I missing a the point here ?

Thanks you in advance for any help :))

Emmanuel



98.9k
Accepted
answer
edited Jul '14

Hello, the name of the service you must use to print the messages must be same as the service you're registering:

$di->set('flash', function() {
    return new \Phalcon\Flash\Session(array(
        'error' => 'alert alert-error',
        'success' => 'alert alert-success',
        'notice' => 'alert alert-info',
    ));
}, true);

and

echo $this->flash->output(); // use "flash" instead of "flashSession"


1.4k
edited Jul '14

wow... It was that simple... I'm a little ashamed now :*)

Thank you very much... I'll try to look twice before posting next time

)