forward + clientscript

Just a little tip

If you use the forward method to call another controller’s action with $exit=false, you will notice that the registered scripts of clientScript will be rendered for each CController’s render call

to avoid that, do the following




//Controller

//extend forward method 

public function forward($route,$exit=true){

  Yii::app()->params['forwarded']=true;

  parent::forward($route,$exit);

  Yii::app()->params['forwarded']=false;

}

//extend clientScript

class myClientScript extends CClientScript{

 public function render(&$output){

  if(Yii::app()->params['forwarded']===true)

	return;

  return parent::render($output);

 }

}

//config/main.php

//use your just created clientScript

...

'components'=>array(

...

'clientScript'=>array('class'=>'myClientScript'),

),



and you are done

Hope this helps

Gustavo