How to flash a message in front-end?

北城余情 提交于 2019-12-11 16:07:52

问题


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.


回答1:


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");
}
?>  


来源:https://stackoverflow.com/questions/54560181/how-to-flash-a-message-in-front-end

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!