php - Yii Property "CListView.X" is not defined -
i new @ yii , trying show list of user on home page , while doing getting error: property "clistview.userlist" not defined. code: sitecontroller.php
class sitecontroller extends controller { // function changed reset file remains same public function actionindex() { $userlist = user::model()->findallbysql($sql); $this->render('index',array('userlist'=>$userlist,)); } } the code view of 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 code getting error: property "clistview.userlist" not defined. if replace $userlist $dataprovider, error changes "fatal error: call member function getdata() on non-object in c:\devcenter\yii\framework\zii\widgets\cbaselistview.php on line 107"
i have 2 questions:
- it seems there special meaning of $dataprovider, please me tell why that.
- i passing $userlist sitecontroller index.php $this->widget(), in _view.php variable changes $data, missing? have read through documentation in yii site yet couldn't follow this.
you have done mistake in syntax of clistview in place of dataprovider have inserted userlist , due getting error undefined userlist
this syntax
$this->widget('zii.widgets.clistview', array( 'userlist'=>$userlist, 'itemview'=>'_view', )); the right syntax shown
$this->widget('zii.widgets.clistview', array( 'dataprovider'=>$userlist, 'itemview'=>'_view', )); and $userlist must valid dataprovider define follow steps provided daniel vaquero
Comments
Post a Comment