Searching using a DropDown, in the admin view quick search

I have the following scenarion

I have 2 mysql tables where I need to search within,

In the 2nd table I have a column with name type with contains numbers 1-4, 1 = Normal user, 2 = Sales user etc. Now the corresponding text is not in the database, the text that belong to these values are defined as constants and thats why I need to dropdown. now if I select a value in the dropdown list the search is not executing

My view looks like this


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

	'id'=>'user-grid',

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

	'filter'=>$model,

	'columns'=>array(

		array(

			'name'=>'acl_id',

			'filter'=>CHtml::dropDownList('user[acl_id]',$data->acl_id,$arr),

			'value'=>'CHtml::encode(user::model()->getTypeByText(acl::model()->getACL($data->acl_id)))',

		),

		array(

			'name'=>'region_id',

			'type'=>'raw',

			'value'=>'CHtml::encode(region::model()->getRegion($data->region_id))',

		),

		array(

			'name'=>'acl_id',

			'header'=>'Username',

			'type'=>'raw',

			'value'=>'CHtml::encode(acl::model()->getUsername($data->acl_id))',

		),

		'name',

		'surName',

		'email',

		'cell',

		'createDate',

		'modDate',

		

		array(

			'class'=>'CButtonColumn',

		),

	),

)); ?>

The search within the model looks like below, please note that the value selected is nopt pulling throug to criteria->addInCondition(‘acl.type’,array($this->acl_id)); , if I replace $this->acl_id with a number the search works, but this needs to be dynamic,


/**

	 * Retrieves a list of models based on the current search/filter conditions.

	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.

	 */

	public function search()

	{

		// Warning: Please modify the following code to remove attributes that

		// should not be searched.


		$criteria=new CDbCriteria;

		$criteria->with = array('region','acl');

		$criteria->compare('region.region',$this->region_id,true);


		if(!empty($this->acl_id)){

			$criteria->addInCondition('acl.type',array($this->acl_id));

		}

		




		$criteria->compare('t.name',$this->name,true);


		$criteria->compare('t.surName',$this->surName,true);


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


		$criteria->compare('t.email2',$this->email2,true);


		$criteria->compare('t.cell',$this->cell);


		$criteria->compare('t.tel',$this->tel);


		$criteria->compare('t.fax',$this->fax);


		$criteria->compare('t.createDate',$this->createDate,true);


		$criteria->compare('t.modDate',$this->modDate,true);


		return new CActiveDataProvider('user', array(

			'criteria'=>$criteria,

		));

	}

Hello, I am new in web programming, but I am using dropdown in the admin page, but the problem is that when I select a option of the list, this erase automatically, this is the code of the view

and this is the code of the search

Thanks in advance.

You have to set the field as safe.

Edit the function rules of the model, add this field to the list:




array('field1, field2', 'safe', 'on'=>'search')