zii.widgets.grid.CGridView, CButtonColumn

This is my code:

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







$dataProvider is CArrayDataProvider.

I am getting this error:

PHP Error


Trying to get property of non-object

Source File

C:\wamp\www\th\yii-1.1.4.r2429\framework\base\CComponent.php(616) : eval()'d code(1)

No source code available.

Stack Trace

#0 C:\wamp\www\th\yii-1.1.4.r2429\framework\base\CComponent.php(616): eval()

Any help please. Thank you.

For some reason my problem was solve with this code:


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







  'viewButtonUrl'=&gt;'Yii::app()-&gt;createUrl(&quot;/controllername/view&quot;, array(&quot;id&quot; =&gt; &#036;data[&#092;'model_id&#092;']))',

  'deleteButtonUrl'=&gt;'Yii::app()-&gt;createUrl(&quot;/controllername/delete&quot;, array(&quot;id&quot; =&gt; &#036;data-&gt;[&#092;'model_id&#092;']))',

  'updateButtonUrl'=&gt;'Yii::app()-&gt;createUrl(&quot;/controllername/update&quot;, array(&quot;id&quot; =&gt; &#036;data-&gt;[&#092;'model_id&#092;']))',





I have change $data->model_id to $data->[\‘model_id\’] since I am using CArrayDataProvider.

For some reason no, you found the answer, you were using CArrayDataProvider and its selfdescribing why you couldnt get $data->id.


good morning,

I’m with the same problem: /

but this solution does not help me,

may be something else?

ready problems solved.

was a problem id.


   i am new to yii and also for php.

I am also face this problem and now using this following code i rectified it.But i don’t know how this lines rectifies that problem.But when we use the CActiveDataProvider why that error is not coming?

'viewButtonUrl'=>'Yii::app()->createUrl("/controllername/view", array("id" => $data[\'model_id\']))',

'deleteButtonUrl'=>'Yii::app()->createUrl("/controllername/delete", array("id" => $data->[\'model_id\']))',

'updateButtonUrl'=>'Yii::app()->createUrl("/controllername/update", array("id" => $data->[\'model_id\']))',

CArrayDataProvider and CSqlDataProvider will return an array of arrays while CActiveDataProvider returns an array of AR objects.


Although this is an old post it is still valuable, but there is some typo

one should read


      'viewButtonUrl'=>'Yii::app()->createUrl("/controllername/view", array("id" => $data[\'model_id\']))',

      'deleteButtonUrl'=>'Yii::app()->createUrl("/controllername/delete", array("id" => $data[\'model_id\']))',

      'updateButtonUrl'=>'Yii::app()->createUrl("/controllername/update", array("id" => $data[\'model_id\']))',

I have change $data->model_id to $data[\‘model_id\’] since I am using CArrayDataProvider.