I have an action (controllerF/actionF) that permits the user to save a model by redirect to another action (controllerA/actionA). The user can be update the model after of submit.
how can redirect the user after saving to the first controllerF/actionF ?
note the actionA can be used directly, so I can’t use
ControllerF extends Controller {
public function actionFirst()
{
Yii::app()->user->setState('quickRedirect', 'thisControllersActionPath');
// Redirect to ControllerA
}
}
ControllerA extends Controller {
public function actionSecond()
{
if (Yii::app()->user->getState('quickRedirect'))
// Redirect to Yii::app()->user->getState('quickRedirect')
}
}
I suspect that your way is the only way! (due to more than one session requests)
The solution I chose is:
if ($model->save()) {
if (Yii::app()->user->hasState('myRedirect'))
$this->redirect(Yii::app()->user->getState('myRedirect'));
else if (Yii::app()->user->returnUrl)
$this->redirect(Yii::app()->user->returnUrl);
else
$this->redirect(('default'));
}