Cdetailview - 2 Columns Instead Of Id

Hello.

view DzieckoHasRodzic


<h1>View DzieckoHasRodzic #<?php echo $model->dziecko_id; ?></h1>


<?php $this->widget('zii.widgets.CDetailView', array(

	'data'=>$model,

	'attributes'=>array(

		//'dziecko_id',

                array('name'=>'dziecko.imie'),

		//'rodzic_id',

                array('name'=>'rodzic.imie'),

	),

)); ?>



Relacje - table dziecko and rodzic have HAS_MANY


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(

			'dziecko' => array(self::BELONGS_TO, 'Dziecko', 'dziecko_id'),

			'rodzic' => array(self::BELONGS_TO, 'Rodzic', 'rodzic_id'),

		);

	}

Problem

I would like to view from my table (id, imie[eng. name], nazwisko[eng.lastname]) instead of id. I read about BELONGS_TO that you need only relation.column to change id from relation. What if I want to view name and lastname instead of id ?

All I’ve manage to do is:

changing the code:


<?php $this->widget('zii.widgets.CDetailView', array(

	'data'=>$model,

	'attributes'=>array(

		//'dziecko_id',

                array('name'=>'dziecko.imie'),

                array('name'=>'dziecko.nazwisko'),

		//'rodzic_id',

                array('name'=>'rodzic.imie'),

                array('name'=>'rodzic.nazwisko'),

	),

)); ?>

and attributeLabels() from model ‘dziecko’ and ‘rodzic’. But it doesn’t change the fact that dziecko[eng. child] can have ‘many’ rodzic[eng. parents]. It will look very bad with that…