GridView filter - change input text filed to dropdown

Good day to all Yii-fellows!

I’m using CGridView for displaying and filtering data, and it’s basic functions work fine,

but I need more ::)

Ok, so in the grid view column-based filtering, each data column by default will display a text field for filtering purposes, but I need some of them to be dropdown lists. For example, “sex” column in Users model is either 0, 1 or 2 (unknown\male\female), so I’d realy like filter column to have simple dropdown instead of text field, because it might become a usability disaster to have to know to type “2” if you’re looking for female users.

Didn’t found anything on that topic yet :huh: Help, please! ::)

Check the filter propery of CDataColumn - http://www.yiiframework.com/doc/api/CDataColumn#filter-detail

Thanks, now I got it!

For those in need :)




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

	'id'=>'user-grid',

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

	'filter'=>$model,

	'columns'=>array(

		'id',

		'display_name',

		'email',

		array(

			'name' => 'joined',

			'value' => 'date("d.m.Y",strtotime($data->joined))',

		),

		array(

			'name'=>'sex',

			'filter'=>array(1=>'Guys', 2=>'Girls'),

		),

		array(

			'class'=>'CButtonColumn',

		),

	),

)); ?>