Problems with GET

I tried to implement a search-function in the First Application.

After submitting in the search-form the URL index.php?SearchUserForm[username]=test&yt0=Search looks right, but the defaultpage will be loaded.



<?php





class SearchUserForm extends CFormModel


{


	public $username;


...


}

and the action:



	public function actionSearch()


	{


		$form=new SearchUserForm;


		$userList=null;





		if(isset($_GET['Search']))


		{


			$form->attributes=$_GET;


			//$userList=$form->search(); for debugging


			$userList=User::model()->findAll();


			$this->redirect('list',array(


				'userList'=>$userList,


			));


		}


		$this->render('search',array('form'=>$form,));


	}

what have i missed?

Consider this:



....


if(isset($_GET['Search'])) //this is true if your search button is named 'Search', right?


		{


			$form->attributes=$_GET['SearchUserForm'];


....


More: 'username' must be listed as 'safeAttribute'…

sorry, no change.

Yes my button is named 'Search'

I added safeAttribute in user model, right?



	public function safeAttributes()


	{


		return array(


			'username',


		);


	}

For me, it seems that yii doesn't recognise the part behind '?' in the URL

Why are you checking for 'Search', I think you should check for 'yt0', no?

This is because the query part (after the question mark) in your form action URL is discarded if the form is submitted using GET method.

You need to store existing GET parameters (in particular the 'r' parameter which stores the route) in hidden fields so that when the form is submitted, these GET parameters are restored.