8 public $params = array(
24 'label' =>
UserModule::t(
'Relation Belongs To', array(), __CLASS__),
25 'fieldType' => array(
'INTEGER'),
26 'params' => $this->params,
27 'paramsLabels' => array(
28 'modelName' =>
UserModule::t(
'Model Name', array(), __CLASS__),
29 'optionName' =>
UserModule::t(
'Lable field name', array(), __CLASS__),
30 'emptyField' =>
UserModule::t(
'Empty item name', array(), __CLASS__),
31 'relationName' =>
UserModule::t(
'Profile model relation name', array(), __CLASS__),
60 $relation = $model->relations();
61 if ($this->params[
'relationName'] && isset($relation[$this->params[
'relationName']])) {
62 $m = $model->__get($this->params[
'relationName']);
64 $m = CActiveRecord::model($this->params[
'modelName'])->findByPk($model->getAttribute($field->varname));
68 return (($this->params[
'optionName']) ? $m->getAttribute($this->params[
'optionName']) : $m->id);
70 return $this->params[
'emptyField'];
84 if ($this->params[
'emptyField']) {
85 $list[0] = $this->params[
'emptyField'];
88 $models = CActiveRecord::model($this->params[
'modelName'])->findAll();
89 foreach ($models as $m) {
90 $list[$m->id] = (($this->params[
'optionName']) ? $m->getAttribute($this->params[
'optionName']) : $m->id);
92 return CHtml::activeDropDownList($model, $field->varname, $list, $htmlOptions = array());