CActiveRecord relation and CGridView/CDetailView

Hi!

I have a problem and I want to know if Yii Framework always manage it.

I have define a relation between 2 models (extending CActiveRecord) Equipement and LibelleEquipement, here is the relations function define in Equipement 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(

                        'libele' => array(self::BELONGS_TO, 'TblLibelleEquipement', 'id'),

			'num0' => array(self::BELONGS_TO, 'TblCategorie', 'num'),

			'tblStation' => array(self::BELONGS_TO, 'TblStation', 'tbl_station_id'),

			'tblEtatEquipements' => array(self::HAS_MANY, 'TblEtatEquipement', 'tbl_equipement_id'),

		);

	}



And here is the relations function in LibelleEquipement :




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(

			'tblEquipements' => array(self::HAS_MANY, 'TblEquipement', 'libele')

		);

	}



My problem is the fact that when I display an equipement trought CGridView/CDetailView an integer is displayed as libele value. I want to know if there is a way to display the corresponding libele string in LibelleEquipement table.

So the user will see a string but, integers is use for relation.

Thanks

This topic has been discussed many time here in the forum.

Please do a search for gridview id name or something like that and you are going to find the solution.

Of course the demo blog app and the guide are also good places to learn how you could achive your goal.

Here are two starting points:

In GRID access the value of the other reference tables

How to display a related HAS_MANY grid