hi
i make crud page that shows the id of foreign key
i want to view the name of foreign key instead of id.
hi
i make crud page that shows the id of foreign key
i want to view the name of foreign key instead of id.
I think you want something like this:
echo $model->relation->name;
See docs.
thanks for your replay it work
i just add
• in _view.php add the following :
<?php echo CHtml::encode($data->getAttributeLabel(‘AdsCompanys’)); ?>:</b>
<?php echo CHtml::encode($data->adsCompanys->AdsCoName); ?>
where getAttributeLabel(‘AdsCompanys’) is the name of table that you want to retrieve the data from.
the $data->relation_name->field you want to retrieve data from it.
• in View.php add the following instead of ‘AdsComapny_Id’:
array(
'name' => 'AdsCompanys_Id',
'value' => $model->adsCompanys->AdsCoName),
where AdsCompany_id is the foreign key
and adsCoName is the field from related table that retrieve the data from.