Eugene
Eugene

Reputation: 49

How to flash a message in front-end?

How can I flash a message like on this page: https://octobercms.com/docs/ui/flashmessage

What should I include and where?

Exactly I need flash a message after an user submitted some form. On Octobercms forum I find kind of difficult ways to do it.

Upvotes: 1

Views: 958

Answers (1)

Zakir hussain
Zakir hussain

Reputation: 631

Include this attribute data-request-flash in your form tag like below

<form data-request-flash >

and add below code on same page/file where your form is

{% flash %}
    <p
        data-control="flash-message"
        class="flash-message fade {{ type }}"
        data-interval="5">
        {{ message }}
    </p>
{% endflash %}

and suppose your method is like below on component then add flash message like this.

<?php 
public function onCustomerRegister(){
    Flash::success("your message is here");
}
?>  

Upvotes: 2

Related Questions