Yii $this->redirect() is not working in action method

Silicon picture Silicon · Dec 26, 2012 · Viewed 7k times · Source

I have created one module using Giix Component. When i am performing create or update action, it renders create and update view properly. But after submitting form, it again calls same create or update method with request data and after calling save method when i set redirection using

$this->redirect(array('view', 'id' => $model->id));

statement. it shows blank screen.

I have also traced this issue and i found that code execution reaching till this statement but after this statement it stops execution. when i am commenting this statement action method executes its default render statement

$this->render('update', array('model' => $model,));

So Please help me what can be the issue with this.

Thanks in advance

Answer

emix picture emix · Dec 26, 2012

Try:

$this->redirect($this->createUrl('update', array('id'=>$model->id)));