guys,pardon…I am still new at this YII-Framework.
i have this issue,
my table is such this :
User = (id, user_name,role_number)
Role = (id,Role_name).
when the data User is listed, I want the role_name to be shown not the ID
the partial of the coding is down below, that i have configured.
user.php =>
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(
‘role_relation’ => array(self::BELONGS_TO, ‘Role’, ‘id’),
);
}
============================================
UserController.php =>
public function actionIndex()
{
$dataProvider=new CActiveDataProvider(‘User’);
$this->render(‘index’,array(
‘dataProvider’=>$dataProvider,
));
}
============================================
index.php =>
$this->widget(‘zii.widgets.grid.CGridView’, array(
‘dataProvider’=>$dataProvider,
‘columns’=>array(
‘id’,
‘user_name’,
‘password’,
array(‘name’=>‘role_number’, ‘header’=>‘Role Name --’,‘value’ =>’$data->role_relation->role_name’ ),
),
));
is there anything I miss from the script above.
please kindly show me to the brighter light guys.
thank You so much…