I want to pass the value of array from one function to another in the same controller. I don’t know how to do it. please help me.
Suppose:
class TestController extends Controller{
public $abc=array();
public function actionOne()
{
$xyz=array();
if(isset($_POST['Student']))
{
//save and then call another action
$this->actionTwo($xyz);
return;
}
else
$this->render('create',array('db'=>$db));
}
public function actionTwo($this->abc)
{
//do something with the array and redirect
$this->render('create');
}
}
Is the above example of passing array correct?
Secondly:-
class TestController extends Controller{
public function actionOne()
{
$xyz=array();
if(isset($_POST['Student']))
{
//save and then call another action
$this->actionTwo($xyz);
return;
}
else
$this->render('create',array('db'=>$db));
}
public function actionTwo($abc=array())
{
//do something with the array and redirect
$this->render('create',array('abc'=>$abc));
}
}
I tried this also, but did not display anything in view? So am i correct this way… or not?
And one more question is:- how to pass the array using redirect function?
example:
class TestController extends Controller{
public function actionOne()
{
$xyz=array();
if(isset($_POST['Student']))
{
//save and then call another action
$this->redirect(array('Two','xyz'=>$xyz);
return;
}
else
$this->render('create',array('db'=>$db));
}
public function actionTwo($xyz=array())
{
//do something with the array and redirect
$this->render('create');
}
}
Please correct me…