Skip to content

Instantly share code, notes, and snippets.

@micronax
Created August 27, 2015 14:06
Show Gist options
  • Save micronax/2a86bd7b1e9c28944b2c to your computer and use it in GitHub Desktop.
Save micronax/2a86bd7b1e9c28944b2c to your computer and use it in GitHub Desktop.
Symfony 2 flash best-practice template for Twitter Bootstrap based Layouts
{% for type, flashes in app.session.flashbag.all %}
{% for flash in flashes %}
<div class="row">
<div class="col-lg-12">
<div class="alert alert-{{ type }}">
<button class="close" data-dismiss="alert" type="button">×</button>{{ flash }}
</div>
</div>
</div>
{% endfor %}
{% endfor %}
<?
// Usage in Controller Actions:
$this->addFlash('success', 'Your registration was successful!');
$this->addFlash('warning', 'This email addres is already registered!');
$this->addFlash('danger', 'Your account is currentl locked!');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment