Building CGridView

I have the following tables in my database:

tick

|idTick|idTema

tema

|idTema|nomeTema

tick.idTema is a foreign key to tema.idTema

The code




$dataProvider=new CActiveDataProvider('Tick');

$this->widget('zii.widgets.grid.CGridView', array(

    'dataProvider'=>$dataProvider,

    'columns'=>array(

        'idtick',         

        'idtema',  

        array(            

            'class'=>'CButtonColumn',

        ),

    ),

));



How can i show nomeTema in the grid ???

thxs !!!

Declare a relation in the Tick model e.g call it rtema. Then use rtema.nomeTema in the grid.

More info on relation here

http://www.yiiframework.com/doc/guide/database.arr

/Tommy

I think you will have to get the dataProvider sorted out in the controller… i.e joining the tables…