Session flash won't accept new CSS classes. **Edit** resets its class before render.

Basically,

<?php
$di->set('flash', function() {
        $flash = new \Phalcon\Flash\Session([
            'error' => 'alert alert-danger',
            'success' => 'alert alert-success',
            'notice' => 'alert alert-info',
        ]);

        return $flash;
    });

Produces <div class="successMessage">The data saved with no errors.</div>

When I do:

<?php
if(empty($errors)){
            $this->view->disable();
            $this->flash->success('The data saved with no errors.');
            $this->response->redirect('dashboard/');
        }

From my controller.

\Phalcon\Flash\Direct() Produces the expected html if I try it with a forward. Any ideas? It seems to be a common one but nothing I have read seems to answer what's actually going on.

edited May '14

I have recently discovered that if I echo the flash message from the controller stage with $this->flash->output(); the class tag is right but if I echo it out in the view with either, {{ flash.output() }}, {{ flashsession.output() }} or <p><?php $this->flash->output() ?></p> in the view then the class tag has been reset by that point. I notice that any echos from a controller materialize via {{ content() }} so my fix for now is to place $this->flash->output(); in the initialize function in my BaseController. I think this may need to be submitted as an issue in Github after all @phalcon ?

I don't know about the different methods you are using to output the flashes, but I found that I needed to set custom classes for both types of flashes in order to get them working consistently.

    //Register the flash service with custom CSS classes
    $di->set('flash', function(){
        $flash = new \Phalcon\Flash\Direct(array(
            'error' => 'alert alert-danger',
            'success' => 'alert alert-success',
            'notice' => 'alert alert-info',
            'warning' => 'alert alert-warning'
        ));
        return $flash;
    });
    $di->set('flashSession', function(){
        $flash = new \Phalcon\Flash\Session(array(
            'error' => 'alert alert-danger',
            'success' => 'alert alert-success',
            'notice' => 'alert alert-info',
            'warning' => 'alert alert-warning'
        ));
        return $flash;
    });

Seems to be a similar situation.