Replacing Int To Some Value Without Using Any Widget (E.g Clistview Or Cgridview)

I have two tables where one attribute is foreign key. I want to display it without using any widgets(e.g CListView or CGridView)

The problem is how to show varchar instead of INT

what I’ve done in the views/name_folder/index.php is

<table id="box-table-a">



         <th scope="col">No</th>

         <th scope="col">Project</th>

         <th scope="col">Contractor</th>







	    foreach($projectDataProvider->data as $p):?>

	       <td><?php echo $p->id;?></td>

	       <td><?php echo $p->project_name;?></td>

	       <td><?php echo $p->contractor_id;?></td> //How to echo $p->contractor_name;				


		<?php endforeach;?>	



result is

No|Project |Contractor|

1 |Web Development| 1 |

2 |Web Design | 3 |

3 |Database Design| 2 |

what I want is

No|Project |Contractor|

1 |Web Development| Alex |

2 |Web Design | Buddy |

3 |Database Design| Charlie |

the problem is quite similar to this but in my case I don’t want to use any widgets, is that possible?

You will have to define a relationship between your models. Then you can reference the related model and its attributes directly.

Hint, read the guide here:

(You probably want to use eager loading.)

Hei, thanks for pointing me to the guide, finally I solved it :wink: