The Code Suddenly Doesn't Work

It’s pretty strange, it worked before, but then suddenly when I come back, it show the error message:


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

	'id'=>'skill-grid',

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

	'filter'=>$model,

	'columns'=>array(

		'id',		

                array(

                    'header'=>'user',

                    'name'=>'user_id',

                    'value'=>'User::getName($data->user_id)'),

// other column

		/*

I read the error message and it revealed that it unable to send $data->user_id to getName($id) function of User model:




Trying to get property of non-object 

......

..\framework\base\CComponent.php(606) : eval()'d code(1): User::getName(null) 



There is no way to fix it to me, anyone got this problem before?

Which model are you calling? User model?

If so, right before the code you posted (inside PHP of course) try this and show us what appears:


CVarDumper::dump( User::model()->findAll() , 10, true ); die;

The problem is User_id=null , so check why is null ?

can you try to edit code to be :


  'value'=>User::getName('$data->user_id'), 

if not work try to add user_id as number


 'value'=>User::getName('2'), 

let us know what happend ?

Thank all, I fixed it, wrong syntax after all :)