Reputation: 2600
How to get CActiveDataProvider
data directly, without using CGridView
?
Controller.php
public function actionList($id)
{
$criteria = new CDbCriteria;
$dataProvider=new CActiveDataProvider('Events', array(
'criteria' => $criteria
));
$this->render('list',array(
'dataProvider'=>$dataProvider,
));
}
View.php:
<?php echo $dataProvider->name; ?> // Return Error
Upvotes: 1
Views: 2418
Reputation: 1181
CActiveDataProvider provides data in terms of ActiveRecord objects , use getData()
method to get all activerecord objects that are in the dataprovider
$models =$dataProvider->getData()
foreach($models as $model)
{
echo $model->name;
}
Upvotes: 10