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.

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!



32.7k
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;
});


2.7k

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

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