Yii Property "CListView.X" is not defined
I am new at Yii and trying to show the list of user on the home page and
while doing so I am getting error: Property "CListView.userlist" is not
defined. Code: SiteController.php
class SiteController extends Controller {
// This is the function which I changed reset is file remains same
public function actionIndex() {
$userlist = User::model()->findAllBySql($sql);
$this->render('index',array('userlist'=>$userlist,));
}
}
The code for view of the site, index.php:
$this->widget('zii.widgets.CListView', array(
'userlist'=>$userlist,
'itemView'=>'_view',
));
In last _view.php:
echo CHtml::encode($data->getAttributeLabel('id'));
Currently in with code I am getting error: Property "CListView.userlist"
is not defined. But if I replace $userlist with $dataProvider, the error
changes to "Fatal error: Call to a member function getData() on a
non-object in C:\devCenter\yii\framework\zii\widgets\CBaseListView.php on
line 107"
I have two questions:
It seems there special meaning of $dataProvider, please me tell why is that.
I am passing $userlist from SiteController to index.php then to
$this->widget(), but in _view.php the variable changes to $data, what am I
missing? I have read through the documentation in Yii site yet I couldn't
follow this.
No comments:
Post a Comment