Redirect To First Controller/action

Hi to Everyone

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


I tried to do that with




but without luck

can anyone advice me a way to do that?


You will be able to use a function redirect($url)

class controllerF extend Controller


  public function actionF()






Hi antares, thanks for response

But your code redirects to another action that I want (first step).

how can I redirect from the redirected action back to the first controller/action after of saving with dynamically way? (and after of two requests)


is it u need another action ?

use a common method (function) inside the 2 actions. Thats the good programming practice.

Hi Rajith

the second action belongs to another controller and can be used also as independent action

for example an eshop user can be either modified his contact information directly from user profile, or in the step of choosing shipping Methods.

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')



Hi waterloomatt

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'))


                else if (Yii::app()->user->returnUrl)





Thanks :)