ayhamhsn - 1 year ago

I used to define an instance of a form builder and rendered its inputs in my structure. but when I want to render the flash messages comes from the response of form in case it success or there are some errors. this is what I have done :

      <div class="contact-form f-san-light">
                {% set form  = form('contactus').to('hello@pixel38.com').get() %}
                {{ form.open({'class' : 'contact-form', 'id' : 'main-contact-form'}) |raw }}
                    <div class="form-group wow fadeInLeft mar9">
                        {{ form.fields.name.input |raw }}
                    </div>
                    <div class="form-group wow fadeInLeft mar9">
                        {{ form.fields.company_name.input |raw }}
                    </div>
                    <div class="form-group drop wow fadeInLeft mar9">
                        {{ form.fields.country.input |raw }}
                    </div>
                    <div class="form-group wow fadeInLeft mar30">
                        {{ form.fields.address.input |raw }}
                    </div>
                    <div class="form-group wow fadeInLeft mar9">
                        {{ form.fields.mobile_number.input |raw }}
                    </div>
                    <div class="form-group wow fadeInLeft  mar30">
                        {{ form.fields.email.input |raw }}
                    </div>
                    <div class="form-group drop wow fadeInLeft mar9">
                        {{ form.fields.subject.input |raw }}
                    </div>
                    <div class="form-group wow fadeInLeft mar9">
                        {{ form.fields.message.input |raw }}
                    </div>
                    <div class="form-group wow fadeInLeft">
                        <button type="submit" class="submit btn primary-color-background f-header-bold">SUBMIT</button>
                    </div>
                {{ form.close |raw }}

            </div>

Answer

dominique - 1 year ago

{% if message_exists('success') %}
    <div class="alert alert-success">
        <button type="button" class="close" data-dismiss="alert">
            <span>&times;</span>
        </button>
        {% for message in message_get('success') %}
            {{ trans(message)|markdown }}
        {% endfor %}
    </div>
{% endif %}

An example of multiple types of messages can be found in /core/pyrocms/starter-theme/resources/views/partials/messages.twig

dominique - 1 year ago

{% if message_exists('success') %}
    <div class="alert alert-success">
        <button type="button" class="close" data-dismiss="alert">
            <span>&times;</span>
        </button>
        {% for message in message_get('success') %}
            {{ trans(message)|markdown }}
        {% endfor %}
    </div>
{% endif %}

An example of multiple types of messages can be found in /core/pyrocms/starter-theme/resources/views/partials/messages.twig

jcastillotx - 1 year ago

There is a notification partial in the template you can use. Just call it in the twig.