Filters Using Relationship Id

I have problem with filters using relationship id like:

in Model

return array(

‘mname’ => array(self::BELONGS_TO, ‘Voilencemethods’, ‘name’),


using in GridView




		'filter'=>CHtml::listData(Voilencemethods::model()->findAll(), 'id', 'name'),


But when i select a value from dropdown list having id like 1 it also load all the name having id 10, 11, 12 …, in short all those IDs having 1.

Kindly any solution?


you must search using name, not id, so your filter shoud be

'filter'=>CHtml::listData(Voilencemethods::model()->findAll(), 'name', 'name'),

why you on earth you wanna do that just change your search method under you model

public function search()



    $criteria->compare('id',$this->id,true); // change true to false (third arg)