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

Data transferred between dispatcher - behaviour ?

Sometimes I see that data submitted to last form is still affecting current action.

For example :

There is a an createAction where new data is added and saved to DB. On successful save, I redirect it to search result page.

  if ($file->save() == true ) {
                            $this->flash->success(_("File uploaded successfully"));
                            return $this->dispatcher->forward([
                                        'action' => 'search'
                            ]);
                        }

By deafult search action should just show all the items from that Modal but it only shows last uploaded file. So data sent in previous $_POST is also processed by search action ie. next action where I forwarded flow. And I have confirmed this by multiple tests.

Probalbly I am missing something obvious, kindly advice.



145.0k
Accepted
answer
edited Jul '18

You doesn't do redirect, you do forward. Forward is done in same request, so it shares the same $_POST $_GET etc. If you need to do redirect then use $this->response->redirect()