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.

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.



130.8k
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()