display data from another model in detailview

hii all,

 I develop one application in yii and in that there is two models name is "InwardTable" and "InwardDetailTable". i need to display item_name in InwardTable's DetailView which is in InwardDetailTable.i try to display item_name using relation on item_id from InwardDetailTable but that not works. even rate,Discount and Amount also not displayed which is in InwardDetailTable same as item_name

My Code is::

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

'data'=&gt;&#036;model,


'attributes'=&gt;array(


	//'inward_detail_id',


	//'inward_detail_inward_id',		


	//'inward_item_id',


	


	array(


		'name'=&gt;'item_name',


		'value' =&gt; '&#036;data-&gt;rel_itemname-&gt;item_name'


	),


	array(


		'name'=&gt;'quantity',


		'value' =&gt; '&#036;data-&gt;quantity',


		'htmlOptions'=&gt;array('style'=&gt;'text-align:right'),


	),


	


	'rate',


	'discount',


	'amount',

in "InwardTable"

Please, share your model’s relation.

my model file of InwardDetailTable is

array(

‘rel_itemname’ => array(self::BELONGS_TO, ‘ItemDetailTable’,‘inward_item_id’),

);

In Search Method ::

‘rel_itemname’ => array(self::BELONGS_TO, ‘ItemDetailTable’,‘inward_item_id’),

Did you try to use "rel_itemname.item_name", like a native attribute from InwardDetailTable?


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

'data'=>$model,

'attributes'=>array(

'rel_itemname.item_name',

'rate',

'discount',

'amount',


?>

When you use CDetailView, you need to change:




'value' => '$data->rel_itemname->item_name'

to:


'value' => $model->rel_itemname->item_name

[color=#000000][font=Arial][size=2] [/size][/font][/color][color=#000000][font=Arial][size=2]Please try this

‘value’ => ‘[/size][/font][/color][color=#000000][font=Arial][size=2]InwardTable::Model()->FindByPk($data->[/size][/font][/color][color=#000000][font=Arial][size=2]rel_itemname)->[/size][/font][/color][color=#000000][font=Arial][size=2]item_name’,[/size][/font][/color]

Thanks For Replying me but,

this code dosn’t work.it display whataver we write.