问题
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