I have a CArrayDataProvider.
$movies=array(
array(
'id'=>1,
'date'=>'...',
'name'=>'...'
),
array(
'id'=>2,
'name' => 'col3',
'value' => '...',
),
array(
'id'=>3,
'name' => 'col3',
'value' => '...',
),
);
And i created CArrayDataProvider below.
$dataProvider1= new CArrayDataProvider(
$movies, array(
'id'=>'id',
'keyField'=>'id',
'sort'=>array(
'attributes'=>array('id'),
'defaultOrder'=>array('id' => false),
),
'pagination'=>array(
'pageSize'=>10,
),
)
);
Here is CGridView.
$this->widget('zii.widgets.grid.CGridView',array('dataProvider' => $dataProvider1,
'columns'=>array(
array('name'=>'id', 'header'=>'#'),
date,
array('name'=>'name', 'header'=>'Name', value='CHtml::link($data->name, array("/movie/view", "id"=>$data->id))')
),
));
I thought that variable $data represents a single element of $movies array. But there is error "Trying to get property of non-object ".
I want that the name column is link and when click on the link, it jumps to movie’s “view” view.
How do i do this? How do i use $data variable?
Does $data->id represents the attribute “id” of “movies” array’s one element?