Sunday, January 12, 2014

Create CListView of a model class in another model's view (Yii)

Suppose we have two models: Project and User, in which each Project owns a number of Users. We wish to display a list of associated users in the project instance's view

Modify the protected/views/project/view.php by adding the following line in the script file:

<?php $this->renderPartial('_viewUser', array('project'=>$model)); ?>

Next create a partial view protected/views/project/_viewUser.php with the following codes for its implementation:

$users=new CActiveDataProvider('User', 
$this->widget('zii.widgets.CListView', array(

No comments:

Post a Comment