Skip to content

Instantly share code, notes, and snippets.

@bahamut45
Created October 14, 2015 05:03
Show Gist options
  • Save bahamut45/0acad131a8796ea8ccd5 to your computer and use it in GitHub Desktop.
Save bahamut45/0acad131a8796ea8ccd5 to your computer and use it in GitHub Desktop.
Symfony Flash Message
<?php
$this->get('session')->getFlashBag()->add(
'notice',
array(
'type' => 'info',
'class' => 'alert alert-info fade in',
'title' => 'Message flash :',
'dismissible' => 'alert-dismissible',
'buttonClose' => '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>',
'message' => 'La page de contact n\'est pas encore disponible, merci de revenir plus tard.'
)
);
?>
{% for flashMessage in app.session.flashbag.get('notice') %}
<div class="{{ (flashMessage.dismissible is defined) ? flashMessage.class : 'alert' }} {{ (flashMessage.dismissible is defined) ? flashMessage.dismissible : '' }}" role="alert">
{{ (flashMessage.buttonClose is defined) ? flashMessage.buttonClose|raw : '' }}
<strong>{{ flashMessage.title }}</strong> {{ flashMessage.message }}
</div>
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment