I have a view showing a list of database entries. Next to each entry is a delete button, to remove the record. When the user submits hits the delete button the go to a delete confirmation form (with yes/no submit buttons). The actual deletion is done in the deleteAction of the Controller. Normally I would, upon confirmation of deletion, simply redirect to a specified route using :
$this->redirect()->toRoute($route, ['action' => 'index']);
What I would like to do is redirect them back to the page they came from. I know I can redirect to the last page they were at with:
$url = $this->getRequest()->getHeader('Referer')->getUri(); return $this->redirect()->toUrl($url);
But this will return me to the delete confirmation page. Technically I would like to go two pages back. Is there a best practice for sending the route you would like to be returned to from within the form? When deleting a particular record from the table, the user can access this from multiple points, so simply redirecting to a static location is not an option.