Hi everyone, I got stuck in this one case.
I try to show username based on id of the user, so I set relation in issue model:
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(
'requester' => array(self::BELONGS_TO, 'Issue', 'requester_id'),
'owner' => array(self::BELONGS_TO, 'Issue', 'owner_id'),
'project' => array(self::BELONGS_TO, 'Project', 'project_id')
);
}
and, I put relation in project model:
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(
'issues' => array(self::HAS_MANY, 'Issue', 'project_id'),
'users' => array(self::MANY_MANY, 'User', 'tbl_project_user_assignment(project_id, user_id)')
);
}
But, I try to see the output of the view.php of issue model can’t show the username although I have put (see attachment)
<?php $this->widget(‘zii.widgets.CDetailView’, array(
'data'=>$model,
'attributes'=>array(
'id',
'name',
'description',
array(
'name'=>'type_id',
'value'=>CHtml::encode($model->getTypeText()),
),
array(
'name'=>'status_id',
'value'=>CHtml::encode($model->getStatusText()),
),
array(
'name'=>'owner_id',
'value'=>CHtml::encode($model->owner->username), //doesn't show up
),
array(
'name'=>'requester_id',
'value'=>CHtml::encode($model->requester->username), //doesn't show up
)
),
));