Hi!
I’m having some doubts about the example:
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$dataProvider,
'columns'=>array(
'title', // display the 'title' attribute
'category.name', // display the 'name' attribute of the 'category' relation
'content:html', // display the 'content' attribute as purified HTML
array( // display 'create_time' using an expression
'name'=>'create_time',
'value'=>'date("M j, Y", $data->create_time)',
),
array( // display 'author.username' using an expression
'name'=>'authorName',
'value'=>'$data->author->username',
),
array( // display a column with "view", "update" and "delete" buttons
'class'=>'CButtonColumn',
),
),
));
I tried to use the $data variable in my project but, instead, error returned!
"PHP Error
Description
Undefined variable: data
Source File
/home/dead_devil_66/www/pi3/protected/views/community/mainindex.php(58)
00046: <br/>
00047:
00048: <div>
00049: <?php $this->widget(‘zii.widgets.grid.CGridView’, array(
00050: ‘id’=>‘community-grid’,
00051: ‘dataProvider’=>$dataProvider->searchPerCommunity($community->id),
00052: ‘filter’=>$dataProvider,
00053: ‘columns’=>array(
00054: ‘id’,
00055: ‘name’,
00056: array(
00057: ‘class’=>‘CLinkColumn’,
00058: ‘label’=>‘permissoes’ . $data->name,
00059: ‘url’=>‘gugu’,
00060: ),
00061: ),
00062: )); ?>
00063: </div>"
My code for the view:
<div>
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'community-grid',
'dataProvider'=>$dataProvider->searchPerCommunity($community->id),
'filter'=>$dataProvider,
'columns'=>array(
'id',
'name',
array(
'class'=>'CLinkColumn',
'label'=>'permissoes' . $data->name,
'url'=>'gugu',
),
),
)); ?>
</div>
This is just an example that i made.
Why is it returning an error? $data exists!!!1