eong
(Rtmsoft)
November 9, 2010, 7:29pm
1
This is my code:
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$dataProvider,
'columns'=>array(
'Description','Url:url',
array('class'=>'CButtonColumn')
),
));
$dataProvider is CArrayDataProvider.
I am getting this error:
PHP Error
Description
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.
eong
(Rtmsoft)
November 9, 2010, 8:34pm
2
For some reason my problem was solve with this code:
<?php
$this->widget(‘zii.widgets.grid.CGridView’, array(
‘dataProvider’=>$dataProvider,
‘columns’=>array(
'attribute1_name',
'attribute2_name',
array(
'class'=>'CButtonColumn',
'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.
For some reason no, you found the answer, you were using CArrayDataProvider and its selfdescribing why you couldnt get $data->id.
Congrats
good morning,
I’m with the same problem: /
but this solution does not help me,
may be something else?
hai,
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\']))',
tri
(tri - Tommy Riboe)
January 7, 2012, 1:46pm
7
CArrayDataProvider and CSqlDataProvider will return an array of arrays while CActiveDataProvider returns an array of AR objects.
/Tommy
cedSha
(Lineaire)
May 8, 2014, 8:36am
8
Although this is an old post it is still valuable, but there is some typo
…
'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.
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.