Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

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



83.2k
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"


967
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

:)