I have three tables as follows: tbl_family, tbl_district, and tbl_district_leader. The families belong to districts and the districts have a district leader. When using the CDetailView I can access in the family view file the items in the family table as shown below for id and telephone.
<?php $this->widget('zii.widgets.CDetailView', array( 'data'=>$model, 'attributes'=>array( 'id', 'telephone', 'district.district_name', 'district.district_leaders_id', 'district.notes', ), )); ?>
When I want to access the items in the related table "tbl_district" I can use the dot as shown above for district_name and notes.
However my problem is the third table. The tbl_district is related to tbl_district_leader by the district_leader_id field but I cant seem to access this third table? Can someone show me the syntax? Thanks?
The Relations in the models are as follows:
//in Family model 'district' => array(self::BELONGS_TO, 'District', 'district_id'), //in District model 'districtLeaders' => array(self::BELONGS_TO, 'DistrictLeader', 'district_leaders_id'), 'familys' => array(self::HAS_MANY, 'Family', 'district_id'), //in DistrictLeader model 'districts' => array(self::HAS_MANY, 'District', 'district_leaders_id'),