CDbCriteria & CGridView Problem

Hi

This is my first post so be gentle with me :D

I’ve just arrived at Yii after using PHP for ages. I’m still getting to grips with the various nuances of yii but it’s going good so far. Read a lot over the past few days and it’s sinking in.

I’m working on a few simple test projects to get my feet wet and after many hours working on this problem I’ve finally admitted defeat. I’m sure it’s simple but for the life of me I can’t figure it out.

I’m trying to make my grid searchable. All works fine apart from the one column that holds the ‘Classification’. The actual value is an integer for the id but I’m displaying the actual name which is what I’d like to search on.

If I search on the integer I get results but if I try to search on the string value (the actual name),I get nothing.

I don’t want to put loads of needless code up here because I’ve seen how annoying that is so I’ll try to just post the salient bits.

My criteria looks like this…




		$criteria->compare('id',$this->id);

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

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

		$criteria->compare('classification',$this->classification,false);

		//$criteria->compare('classification',$this->classificationName,true);



and my admin view code looks like this…




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

	'id'=>'questions-grid',

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

	'filter'=>$model,

	'columns'=>array(

		'question',

		'subject_id',

		array(

		'name'=>'classification',

		'value'=>'$data->classificationName->id.",

				" .$data->classificationName->classification'

		),

        array(

                'class' => 'CButtonColumn',

        ),

	),

)); ?>



Hopefully that’s enough for somebody more adept with yii to see the obvious mistake I’m making but if not please let me know what you need.

Regards

Steve

this is what you are looking for: http://www.yiiframework.com/wiki/281/searching-and-sorting-by-related-model-in-cgridview

Thanks for that. Looks like exactly what I need. Reading it now.

Steve