I have a page /form
with a form that submits to /profiles/create
. In my ProfilesController
in the createAction
method I have
if (!$profile->save()) {
$this->flash->error($profile->getMessages());
if (!is_null($this->request->getServer('HTTP_REFERER'))) {
return $this->dispatcher->forward($this->request->getServer('HTTP_REFERER'));
}
}
with the intention being to redirect the user back to \form
if they came from there but still show the flash message explaining what went wrong (which is why I was using forward instead of redirect since redirect would remove the flash messages).
However, $this->dispatcher->forward()
requires an array but $this->request->getServer("HTTP_REFERER")
returns a string. How do I get the array needed from this string? Or what should I use instead of dispatcher->forward()
?