21 'label' =>
UserModule::t(
'Relation Belongs To', array(), __CLASS__),
22 'fieldType' => array(
'INTEGER'),
23 'params' => $this->params,
24 'paramsLabels' => array(
25 'modelName' =>
UserModule::t(
'Model Name', array(), __CLASS__),
26 'optionName' =>
UserModule::t(
'Lable field name', array(), __CLASS__),
27 'emptyField' =>
UserModule::t(
'Empty item name', array(), __CLASS__),
28 'relationName' =>
UserModule::t(
'Profile model relation name', array(), __CLASS__),
53 $relation = $model->relations();
54 if ($this->params[
'relationName'] && isset($relation[$this->params[
'relationName']])) {
55 $m = $model->__get($this->params[
'relationName']);
57 $m = CActiveRecord::model($this->params[
'modelName'])->findByPk($model->getAttribute($field->varname));
61 return (($this->params[
'optionName']) ? $m->getAttribute($this->params[
'optionName']) : $m->id);
63 return $this->params[
'emptyField'];
77 if ($this->params[
'emptyField']) {
78 $list[0] = $this->params[
'emptyField'];
81 $models = CActiveRecord::model($this->params[
'modelName'])->findAll();
82 foreach ($models as $m) {
83 $list[$m->id] = (($this->params[
'optionName']) ? $m->getAttribute($this->params[
'optionName']) : $m->id);
86 return CHtml::activeDropDownList($model, $field->varname, $list, $htmlOptions = array());