Cant Change Filter Value, After Pagination

hi folks,

here is the problem. filter is not working after pagination triggered. (when go to the next page)

here is my model




class UserForm extends CActiveRecord

{

	public $email;

	

	public function tableName()

	{

		return 'user_profile';

	}


        public function rules()

        {  

                ...

                array('email, ptype_id, nickname', 'safe', 'on'=>'search'),

                ...

        }

        public function relations()

        {	

		return array(

			'user' => array(self::BELONGS_TO, 'User', 'user_id'),

		);

	}


        public function search()

	{

		$criteria=new CDbCriteria;		

		$criteria->compare('nickname',$this->nickname,true);

		$criteria->with = array('user');

		$criteria->compare('user.user_email', $this->email, true);		

		return new CActiveDataProvider($this, array(

			'criteria'=>$criteria,

			'pagination' => array('pageSize' => 10) 

		));

	}



And here is my admin view




<?php $this->widget('zii.widgets.grid.CGridView', array(

	'id'=>'user-profile-grid',

	'dataProvider'=>$model->search(),

	'filter'=>$model,

	'columns'=>array(

		'profile_id',

		array(

                     'name' => 'user.user_email',

                     //'header' => 'EMAIL',

                     'filter' => CHtml::activeTextField($model, 'email'),

                     'value' => '$data->user->user_email',

                ),

		'nickname',

		array(

			'class'=>'CButtonColumn',

		),

	),

)); ?>



Filter is working fine before pagination triggered. When I go to the next page, I cant change filter value for email.

Am I missing something?

Any idea?

after $_GET[‘pageSize’], $model->attributes Must be set

thank you for your reply,

can you tell me please how do I do that?




$model = new UserForm('search');

$model->unsetAttributes();


$data = Yii::app()->request->getParam('UserForm');        

if ($data) {

    $model->attributes = $data;

}



but I already have this, in my controller.




        public function actionAdmin()

	{

		$model=new UserForm('search');

		$model->unsetAttributes();  // clear any default values

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

			$model->attributes=$_GET['UserForm'];


		$this->render('admin',array(

			'model'=>$model,

		));

	}



Are you sure form data is not send by POST?

yeap, I am sure about this, all I have in my view page is here

admin.php




<h1>Manage User Profiles</h1>


<?php $this->widget('zii.widgets.grid.CGridView', array(

	'id'=>'user-profile-grid',

	'dataProvider'=>$model->search(),

	'filter'=>$model,

	'columns'=>array(

		'profile_id',

		array(

          'name' => 'user.user_email',

          'header' => 'EMAIL',

          'filter' => CHtml::activeTextField($model, 'email'),

          'value' => '$data->user->user_email',

        ),

		'nickname',

		array(

			'class'=>'CButtonColumn',

		),

	),

)); ?>



Do you need ‘filter’ => CHtml::activeTextField($model, ‘email’), at all?

I’m not sure - do you have to set safe rule for the related model as well?

it has to be


$_GET['UserForm'];

filter params are passed as query string

change your column like so


array(

          'name' => 'email',

          'value' => '$data->user->user_email',

        ),

Right, you have to set ajaxType=>‘POST’ for POST, GET is default.

after set $model2->attributes, set $model->email = $_POST[model][email]

thank you, this helps.