Change $_GET in render

Is there a way to change a $_GET variable while using $this->render(‘view’) in a controller? I can use $this->redirect to do what I am trying to do (reload the page with no $_GET variable), but then I cannot pass $_POST data, which is less than optimal. Or is there something I’m missing?

Though I am not sure what you would like to do, is this code piece of any help?

http://www.yiiframework.com/forum/index.php?/topic/2608-debug-my-source-to-get-correct-pagination-result/page__p__14616__fromsearch__1&#entry14613

This code piece for the pagination aims to pass the parameter from POST to GET at first time (on the 1st page), and to use the parameter from GET at the next time (after the 2nd page).

Hmm, possibly. Maybe I’m just doing this the completely wrong way. Here’s what I’m trying to do: I have a view with a form, and I want to intially show the form with all fields disabled. If the user clicks an ‘edit’ link, the disabled attribute is removed from all fields.

Here’s a snippet of my view:




if($_GET['edit']==1) {

	$disabled = '';

	$disabledkey = '';

	$edit = 'Edit ';

} else {

	$disabled = 'disabled';

	$disabledkey = 'disabled';

}

?>

...

echo CHtml::link('Edit',array('member/users','edit'=>1,$disabledkey=>$disabled));

...

echo CHtml::activeTextField($model,'username',array('size'=>30,'maxlength'=>30,$disabledkey=>$disabled));



That part works fine, although it’s not exactly elegant.

Here’s the controller:




	public function actionUsers() 

	{		

		$model = Users::model()->findByPk(Yii::app()->user->id);

		if(isset($_POST['users'])) {

			$model->scenario = 'memberUpdate';

			$model->attributes = $_POST['users'];

			$status = $model->save();

			$model = Info::model()->findByPk(Yii::app()->user->id);

			$url = $this->createUrl('member/users');

			$this->redirect($url);

		} 

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

	}



If I call $this->render(…) instead of $this->redirect($url), the $_GET variable stays set. If I call $this->redirect($url), the $_GET variable disappears, but then I can’t (or don’t know how to) pass the ‘status’ variable (the $status variable will trigger a message telling users whether the save was successful or not) - unless, there’s a way to make that display if the model doesn’t have any error messages.

Or maybe the way I’m doing this is just making it a lot more complicated than it needs to be :blink:

Though I do not know well about what you would like to do,

Please try below.




     $url = $this->createUrl(array('member/users','model'=>$model,'status'=>$status));

     $this->redirect($url);



I suppose that would pass it, but then I’ve got a mess of a URL to look at :( but then again, the average user probably doesn’t even know what a URL is or care how pretty it is, so…