I have a grid in which I need to bind a list of months. I have create a list of months and bind it to the list as shown below.
$items = $this->getMonths();
$dataProvider= new CArrayDataProvider(array(),array('keyField'=>false));
$dataProvider->setData($items);
$this->render('monthlyReports',
array('model'=>$this->loadModel($_POST['Users']['user_id']),
'dataProvider'=>$dataProvider,));
Upto this every thing is working fine. Now in the view file I have the following code
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'users-grid',
'dataProvider'=>$dataProvider,
'columns'=>array(
'Months',
array(
'name'=>'Months',
'value'=>'$data->Months'),
)));
Now the problem is that I am not able to access Months as $data->Months in the View file where as if I directly access months I can do so. How can I access the Months as $data->Months. The $items array that I am passing has the following values:
Array
(
[0] => Array
(
[Months] => January
)
[1] => Array
(
[Months] => February
)
[2] => Array
(
[Months] => March
)
[3] => Array
(
[Months] => April
)
[4] => Array
(
[Months] => May
)
[5] => Array
(
[Months] => June
)
)
You are passing array data so you need to access your data as '$data["Months"]'
.