Simple Markup

To generate a flash message just use a flash macro:

{{ flash(type, message, close, use_raw) }}
{{ advanced_flash(type, heading, message, close_tag, use_raw) }}

Type Options

To get a yellow box use 'warning' as type

To get a red box use 'danger' as type

To get a green box use 'success' as type

To get a blue box use 'info' as type


Using html inside the message

To use html in the message as we do here set use_raw to true


Close Button

Bootstrap comes with a great jQuery plugin that supports alert messages, making dismissing them quick and easy.

To get the close button set the close argument true


Advanced heading

If you need more advanced flashed you can set a heading, or even omit it setting heading to false


Close Tag

The advanced flash macro has the possibility to set a close_tag it should be either 'button' or 'a

Simple alerts

Supply your type, message and an optional close icon, and important , if you use html inside the message set use_raw to true!:

Warning! Best check yo self, you're not looking too good.
Oh snap! Change a few things up and try submitting again.
Well done! You successfully read this important alert message.
Heads up! This alert needs your attention, but it's not super important.

Advanced alerts

Supply your type, heading, message and an close tag:

Warning!

Best check yo self, you're not looking too good. Nulla vitae elit libero, a pharetra augue. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

Oh snap!

Change a few things up and try submitting again. Nulla vitae elit libero, a pharetra augue. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

Well done!

ou successfully read this important alert message. Nulla vitae elit libero, a pharetra augue. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

Heads up!

This alert needs your attention, but it's not super important. Nulla vitae elit libero, a pharetra augue. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

A common thing in Symfony2 is to use Session Flashes to provide Messages on the "next request"

We provide a block in the template called "session_flash" this looks like

{% block flashes %}
    {% if app.session.flashbag.peekAll|length > 0 %}
    <div class="row">
        <div class="col-lg-12">
        {{ session_flash() }}
        </div>
    </div>
    {% endif %}
{% endblock flashes %}

To provoke a REDIRECT and see some flashes Click Here

Dont forget to import the macro into the current template:

{% from 'MopaBootstrapBundle::macros.html.twig' import label, badge %}

Badges

Badges are small, simple components for displaying an indicator or count of some sort. They're commonly found in email clients like Mail.app or on mobile apps for push notifications.

Available classes

Example Markup
42
{{ badge(42) }}

Labels

Label annotate text and can simply be used inline

Available classes

Name Example Markup
Default Default
{{ label('Default') }}
Primary Primary
{{ label('Primary', 'primary') }}
Success Success
{{ label('Success', 'success') }}
Info Info
{{ label('Info', 'info') }}
Warning Warning
{{ label('Warning','warning') }}
Danger Danger
{{ label('Danger', 'danger') }}
Fork me on GitHub