I have 4 tables:
[list=1]
[*]User
[*]Pupil
[*]PupilHasUser
[*]PupilGroup
[/list]
I want to display all info in PupilHasUser. Now I don’t know how should i preview name of pupil group in PupilHasUser view.
Pupil 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(
'pupilGroupPupilGroup' => array(self::BELONGS_TO, 'PupilGroup', 'pupil_group_pupilGroupId'),
'pupilHasUsers' => array(self::HAS_MANY, 'PupilHasUser', 'pupil_pupilId'),
);
}
Pupil group 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(
'pupils' => array(self::HAS_MANY, 'Pupil', 'pupil_group_pupilGroupId'),
);
}
PupilHasUser 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(
'pupilPupil' => array(self::BELONGS_TO, 'Pupil', 'pupil_pupilId'),
'userUser' => array(self::BELONGS_TO, 'User', 'user_userId'),
'PupilGroup'=>array(self::HAS_ONE,'PupilGroup',array('pupil_group_pupilGroupId'=>'pupilGroupId'),'through'=>'pupilPupil'),
);
}
PupilHasUser view.php:
<div class="flash-notice">Dane ucznia.</div>
<?php $this->widget('zii.widgets.CDetailView', array(
'data'=>$model,
'attributes'=>array(
array(
'name'=>'pupilPupil.fullname',),
array(
'name'=>'pupilPupil.status',),
array(
'name'=>'pupilPupil.genre',),
array(
'name'=>'pupilPupil.birth_date',),
array(
'name'=>'pupilPupil.start_time',),
array(
'name'=>'pupilPupil.end_time',),
array(
'name'=>'pupilPupil.pupil_group_pupilGroupId',),
'PupilGroup.pupilGroupTitle',
)); ?>
I can get attributeLabels() from PupilGroup but not the value.(Not set)