Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Cdetailview - 2 Columns Instead Of Id

$
0
0
Hello.
view DzieckoHasRodzic
Posted Image

<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

Posted Image

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 ?

Viewing all articles
Browse latest Browse all 18717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>