I pulled data from my API in JSON format
and convert to a CArrayDataProvider in my controller.
The data looks like this (using print_r();
When I call index.php
In _view.php
I get an error saying
"Trying to get property of non-object"
But don't understand why.
If I remove the second line, the array of 100 gets printed out to the view just fine as
"ID:"
"ID:"
...
What am I missing
and convert to a CArrayDataProvider in my controller.
$arraydata = array(); for ($i=$start_element ; $i<$start_element+$num_elements; $i++) { $arraydata[$i] = array( "id" => $obj->response->publishers[$i]->id, "name" => $obj->response->publishers[$i]->name ); }
The data looks like this (using print_r();
CArrayDataProvider Object ( [keyField] => id [rawData] => Array ( [0] => Array ( [id] => 121422 [name] => Default Real Time ) [1] => Array ( [id] => 122328 [name] => Rogue ) [2] => Array ( [id] => 122330 [name] => ARTIST ) [3] => Array ( [id] => 122510 [name] => The Rugged ) ...
When I call index.php
$this->widget('zii.widgets.CListView', array( 'dataProvider'=>$dataProvider, 'itemView'=>'_view', ));
In _view.php
<div class="view"> <?php echo 'ID:'; ?> <?php echo $data->id; ?> </div>
I get an error saying
"Trying to get property of non-object"
But don't understand why.
If I remove the second line, the array of 100 gets printed out to the view just fine as
"ID:"
"ID:"
...
What am I missing