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.

Dispatcher triggers isPost after forward

Hi fellow Phalconers,

I'm using the dispatcher to forward a user to the next form/view after first saving and validating the current form (see controller snippet below):

if ($form1->save())) {
    return $this->dispatcher->forward(array(
        'controller' => 'index',
        'view' => 'form2'

However, this is triggering the isPost() on form2, and therefore the form's validation.

if ($this->request->isPost()) {
    // form processing, checking valid, save, etc.

Is there anyway to stop the forward from triggering isPost? I did try:

if (($this->request->isPost()) && (!$this->dispatcher->wasForwarded())) {
    // form processing, checking valid, save, etc.

But unfortunately this then stops 'form2' from being processed.


What about redirecting using response?

I am trying to keep the URL the same - e.g.

Hmm, Phalcon\Http\Request doesn't have a wasForwarded method, are you trying to use Phalcon\Dispatcher::wasForwarded like this:

if (($this->request->isPost()) && (!$this->dispatcher->wasForwarded()))


edited Jul '14

Yes Max you are correct, sorry was a typo (have edited the original post).

However as mentioned running that code prevents the validation from occuring when I do then press to submit.

edited Jul '14


$this->view->form = $form;


if ((($this->request->isPost())) && ($this->dispatcher->getPreviousActionName() != 'form1')) {

$this->view->form = $form;