Displaying Messages


Introduction

Pyro flashes session data to display messages to the user. For example if a form is successfully submitted a success message will be pushed to the user letting them know all is well.

Below is an example snippet generated from using make:addon to display any and all messages available using Bootstrap:

{% verbatim %}
<section id="messages">

    {# Success Messages #}
    {% if message_exists('success') %}
        <div class="alert alert-success alert-dismissible">
            <button type="button" class="close" data-dismiss="alert">
                <span>&times;</span><span class="sr-only">Close</span>
            </button>

            {% for message in message_get('success') %}
                {{ trans(message)|markdown }}
            {% endfor %}
        </div>
    {% endif %}

    {# Informational Messages #}
    {% if message_exists('info') %}
        <div class="alert alert-info alert-dismissible">
            <button type="button" class="close" data-dismiss="alert">
                <span>&times;</span><span class="sr-only">Close</span>
            </button>

            {% for message in message_get('info') %}
                {{ trans(message)|markdown }}
            {% endfor %}
        </div>
    {% endif %}

    {# Warning Messages #}
    {% if message_exists('warning') %}
        <div class="alert alert-warning alert-dismissible">
            <button type="button" class="close" data-dismiss="alert">
                <span>&times;</span><span class="sr-only">Close</span>
            </button>

            {% for message in message_get('warning') %}
                {{ trans(message)|markdown }}
            {% endfor %}
        </div>
    {% endif %}

    {# Error Messages #}
    {% if message_exists('error') %}
        <div class="alert alert-danger alert-dismissible">
            <button type="button" class="close" data-dismiss="alert">
                <span>&times;</span><span class="sr-only">Close</span>
            </button>

            {% for message in message_get('error') %}
                {{ trans(message)|markdown }}
            {% endfor %}
        </div>
    {% endif %}

</section>
{% endverbatim %}