0

How I can redirect from one action on controller to another action on different controller with parameter?

I got number controller->number action to where I want go with one parameter, from index controller->index action.

2 Answers 2

1
$redirector = $this->_helper->getHelper('Redirector');

$redirector->gotoSimple(
    'action', // action to redirect to
    'controller', // controller to redirect to
    'default', // module
    array('param1' => 'test', 'param2' => 'test2') // params
);
Sign up to request clarification or add additional context in comments.

3 Comments

Something is it right a got error like this:Notice: Undefined property: CrudController::$_redirector in C:\xampp\htdocs\kdd\application\controllers\CrudController.php on line 23 Fatal error: Call to a member function gotoSimple() on a non-object in C:\xampp\htdocs\kdd\application\controllers\CrudController.php on line 23
Sorry was an error in my example. $this->_redirectors has to be $redirector.
ok, it is works when to param I pass string but how I can pass $var. Something like: $redirector->gotoSimple( ....... 'default', // module array('number'=> $number ) // params ); when I try pass like this a got error: Message: SQLSTATE[21000]: Cardinality violation: 1241 Operand should contain 1 column(s) Request Parameters: array ( 'controller' => 'number', 'action' => 'number', 'number' => array ( 0 => 'crud', 1 => 'create', 2 => '111111111', 3 => 'default', ), 'module' => 'default', )
0

Try this :

$params = array('user' => $user, 'mail' => $mail);


$this->_helper->redirector($action, $controller, $module, $params);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.