Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Flash Messages

Hello, i want to create flash messages

At services file i have

$di->set( 'flash', function () { return new Phalcon\Flash\Direct(array( 'error' => 'alert alert-dismissable alert-danger', 'success' => 'alert alert-dismissable alert-success', 'notice' => 'alert alert-dismissable alert-info', )); } );

At controller i am doing

    $this->flash->success("Edit Successfull");
  $this->dispatcher->forward(array(
      'controller' => 'test',
      'action' => 'edit',
      'params'=>array($hotel_id)
  ));

And it works, but the url is changed to test/update from test/edit/id

What i want is the url remain to test/edit/id

cheers



4.0k

I guess that you post form data to test/update. If true, then: use not Phalcon\Flash\Direct but \Phalcon\Flash\Session and not forward but redirect.



3.6k
Accepted
answer

So i found the solution.... The service must be like this

$di->set( 'flash', function () { return new Phalcon\Flash\Direct( array( 'error' => 'alert alert-dismissable alert-danger', 'success' => 'alert alert-dismissable alert-success', 'notice' => 'alert alert-dismissable alert-info', )); } );

and the controller must be like this

$this->flash->success("Edit Successfull"); $this->views->disabled(); $this->responcse->redirect('controller/action');

And either using volt or phtml you must insert that

<p><?php $this->flashSession->output() ?></p>

cheers