hi…
I get problem when using CDetailView
here is my model
Class SuperAdmins extends CActiveRecord {
....
public function findUsername($userId){
if(!isset(self::$_model)){
self::loadModel();
}
$Criteria = new CDbCriteria();
$Criteria->condition = "id = '$userId'";
$result = self::$_model->find($Criteria);
return $result->username;
}
}
when I try to display with CDetailView the result is still ID user not username. but when I try to set manually like this:
Class SuperAdmins extends CActiveRecord {
....
public function findUsername($userId){
if(!isset(self::$_model)){
self::loadModel();
}
$Criteria = new CDbCriteria();
$Criteria->condition = "id = '1'"; // I sett manuall id = '1' and it works
$result = self::$_model->find($Criteria);
return $result->username;
}
}
here is the view
$this->widget('zii.widgets.CDetailView', array(
'data' => $model,
'attributes'=>array(
'id',
'display_name',
'email',
'username',
'created_time:datetime',
array(
'name' => 'created_by',
'value' => SuperAdmins::findUsername($data->created_by) // it doesn't work
),
'edited_time:datetime',
array(
'name' => 'edited_by',
'value' => SuperAdmins::findUsername($data->edited_by) // it doesn't work
),
....
),
));
how to resolve this problem…
thanks…