We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

how to show a html page after Phalcon\Flash\Direct show the success message with a specific time

when I use the Phalcon\Flash\Direct to show a success message, just like

$this->flash->success("The post was correctly saved!");
return $this->dispatcher->forward(array("action" => "index"));

my question is, how to forward to the index action automatically after a specific time, for example in 2 seconds?

thanks



27.7k
Accepted
answer
edited Dec '14

Hmmm, if what you mean is the users notice "The post was correctly saved!" , and after 2 second the page is redirected to index, you need a javascript in the client side to redirect the page.

Or , it would be simpler if you reserve some space in the top of index, set the flash in your transaction action, and directly redirect to index:

<!-- app/views/contact/index.phtml -->

<body>
<section id="notification">
    <?php $this->flashSession->output() ?>
</section>
....
</body>