How To Properly Set Cgridview Column Value

Hi, I’m a beginner here, very interested in Yii.

Lately I’ve been trying to create a project with Yii,

But I come across this problem where the CGridVeiw in Admin controller is showing the value of area_id instead of the name

this is what I’ve tried, but it’s not working


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

	'id'=>'property-grid',

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

	'filter'=>$model,

	'columns'=>array(

		'id',

		'create_time',

		'property_code',

		'type',

		array(

                    'name' => 'area_id',

                    'value' => '$model->area->name'

                ),

		'category',

		array(

		    'class'=>'CButtonColumn',

		),

	),



please kindly guide me, thanks before

You should use $data instead $model inside cgridview.


		array(

                    'name' => 'area_id',

                    'value' => '$data->area->name'

                ),

It’s working , thanks !!

I don’t know that $data exists, but where’s it coming from ?