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

how to define the CSS class about flashSession

there are two way to use flash message, Direct or Session. with the Direct, we can register the flash service with custom CSS classes, just like

$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;
});

so the html code with Twitter bootstrap

<div class="errorMessage">too bad! the form had errors</div>

will become

<div class="alert alert-danger">too bad! the form had errors</div>

my question is how can it work with flash session.

thanks!



51.1k
Accepted
answer

Just set flashSession as you defined flash

$di->set('flashSession', function () {
    $flashSession = new YourFalshSessionHandler(
        array(
            'error'   => 'alert alert-danger',
            'success' => 'alert alert-success',
            'notice'  => 'alert alert-info',
            'warning' => 'alert alert-warning'
        )
    );

    return $flashSession;
});


5.0k

thanks for your answer,

should I need to define my own FlashSessionHandler ? and how to define ?

can you just give me a example ?

Just set flashSession as you defined flash

$di->set('flashSession', function () {
   $flashSession = new YourFalshSessionHandler(
       array(
           'error'   => 'alert alert-danger',
           'success' => 'alert alert-success',
           'notice'  => 'alert alert-info',
           'warning' => 'alert alert-warning'
       )
   );

   return $flashSession;
});