我有 2 个模型:项目和用户。在项目中:
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
"users"=>array(self::MANY_MANY, 'User',
'projects_users(project_id, user_id)'),
);
}
我想列出实际项目中的所有用户,$model 包含实际项目:
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'user-grid',
'dataProvider'=>$model->users,
'columns'=>array(
'ID',
'username',
'displayname',
'firstname',
'lastname',
'email',
/*
'password',
'isAdmin',
*/
array(
'class'=>'CButtonColumn',
'template'=>'{delete}',
),
),
)); ?>
不幸的是,我收到一个错误:
Fatal error: Call to a member function getData() on a non-object in /var/www/vhosts/aevers.com/editor/framework/zii/widgets/CBaseListView.php on line 107