Ad

How To Flash A Message In Front-end?

- 1 answer

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.

Ad

Answer

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");
}
?>  
Ad
source: stackoverflow.com
Ad