I have a form after validation if any error occur the page will redirected to the edit itself with an error message.How to pass previous data and an error message through redirect() in typo3 ?
$this->redirect($action_name,$controllername, $extensionName, array('data',$data));
Is it right?
my action name is 'edit'
But it is redirect to 'list'
.Please help me to solve this issue.
The arguments to pass to the redirect-target have to be given as associative array. The key is the argument name (as in the actions method header, without the
$
), the value is the argument value. Looks like this:How exactly
$data
is encoded in the URL depends on its type. Persistent objects are encoded as their ID, scalars are encoded as simple strings. How they arrive in the other action depends on that actions typehints and@param
annotations.To redirect to the same controller or extension, you can pass
$controllerName
and$extensionName
asnull
.Jost's answer is sufficient to your question but if you want to know more:
Reference: extBase Fluid Book
The arguments are passed as an array with key value pairs, where the key is the parameter name. This assumes that your target action has a parameter named "data".
$this->redirect($action_name,$controllername, $extensionName, array('data' =>$data));