FlashSession Suggestion - Dismissable Alerts

Within flashSession, you can specify custom CSS classes for alerts, in this instance we're using boostrap.

$di->set('flashSession', function() {

    $flash = new flashSession(array(

        'error'   => 'alert alert-danger alert-dismissable',
        'success' => 'alert alert-success alert-dismissable',
        'notice'  => 'alert alert-info alert-dismissable',
        'warning' => 'alert alert-warning alert-dismissable'
    ));

    return $flash;
});

So although the alert-dismissable is present and pushed out, we can't deploy the code for the close button within that alert.

<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>

Some would probably suggest putting this into same place where the text for the alert is but you end up getting the code priniting to screen. Which in a way is quite secure.

The suggestion then is something as easy as

$this->flashSession->error('Please specify an e-mail address', TRUE);

Where TRUE enables a close within the alert div.

Hi @mattratcliff86 the right way make your own flash session service like this

class MyOwnFlash extends \Phalcon\Flash\Session {
    /**
     * @param string $type
     * @param string $message
     * @return string
     */
    public function message($type, $message)
    {        
        $message = '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><p>'.$message.'</p>';

        return parent::message($type, $message);
    }
}

Then just set this custom flash service in your DI replacing the existing flashSession and that its all

Good luck