How To Gridview Id Instead Of Foreign Key Values That Means Name

Iam new in yii framework iam using two tables

1- ex_name_details


in my admin view code is

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









how to fetch instead of exSubtype into subtype table name how to fetch please help

Not 100% sure what you wanted to do, but have you read this wiki? I guess that may be useful for you.

I have using two tables name_details and sub_type , name_table have a foreign key of sub_type table ,now what i want to display sub_type name instead of foriegn key field in name_table ,thats its


u can try the like below code but make sure u can check the proper relation



                    'header'=>'Liquor Category',


                    'filter'=>GxHtml::listDataEx(LiquorCategory::model()->findAllAttributes(null, true)),

                    'htmlOptions' => array('width' => '20%'),


i try that way its show the error message shows in my code ,please will find my coding below attached and would

tell me what is wrong

can you attach the table & both the model files… and screen shot of error message.

I am not able to understand, what you are trying to do…

If you want show name instead of id in grid, you need to do change in ‘xecise.php’ as below,






Put actual model name in ‘ModelName’.

that one is not working ,i attached the screen shot of my gridview how to exercisetype id instead of ExerciseTypeName this two i make foreign key relation pls help anyone