Public Attributes |
| $params |
Detailed Description
Definition at line 3 of file UWrelBelongsTo.php.
Member Function Documentation
UWrelBelongsTo::editAttribute |
( |
|
$model, |
|
|
|
$field, |
|
|
|
$htmlOptions = array() |
|
) |
| |
- Parameters
-
$model | - profile model |
$field | - profile fields model item |
$params | - htmlOptions |
- Returns
- string
Definition at line 81 of file UWrelBelongsTo.php.
{
$list = array();
if ($this->params['emptyField']) {
$list[0] = $this->params['emptyField'];
}
$models = CActiveRecord::model($this->params['modelName'])->findAll();
foreach ($models as $m) {
$list[$m->id] = (($this->params['optionName']) ? $m->getAttribute($this->params['optionName']) : $m->id);
}
return CHtml::activeDropDownList($model, $field->varname, $list, $htmlOptions = array());
}
Widget initialization
- Returns
- array
Definition at line 20 of file UWrelBelongsTo.php.
References UserModule\t().
{
return array(
'name' => __CLASS__,
'label' =>
UserModule::t(
'Relation Belongs To', array(), __CLASS__),
'fieldType' => array('INTEGER'),
'params' => $this->params,
'paramsLabels' => array(
'optionName' =>
UserModule::t(
'Lable field name', array(), __CLASS__),
'emptyField' =>
UserModule::t(
'Empty item name', array(), __CLASS__),
'relationName' =>
UserModule::t(
'Profile model relation name', array(), __CLASS__),
),
);
}
UWrelBelongsTo::setAttributes |
( |
|
$value, |
|
|
|
$model, |
|
|
|
$field_varname |
|
) |
| |
Allows to set attributes
- Parameters
-
$value | |
$model | |
$field_varname | |
- Returns
- string
Definition at line 45 of file UWrelBelongsTo.php.
UWrelBelongsTo::viewAttribute |
( |
|
$model, |
|
|
|
$field |
|
) |
| |
Returns attribute
- Parameters
-
Profile | $model | profile model |
string | $field | profile fields model item |
- Returns
- string
Definition at line 58 of file UWrelBelongsTo.php.
{
$relation = $model->relations();
if ($this->params['relationName'] && isset($relation[$this->params['relationName']])) {
$m = $model->__get($this->params['relationName']);
} else {
$m = CActiveRecord::model($this->params['modelName'])->findByPk($model->getAttribute($field->varname));
}
if ($m) {
return (($this->params['optionName']) ? $m->getAttribute($this->params['optionName']) : $m->id);
} else {
return $this->params['emptyField'];
}
}
Member Data Documentation
Initial value: array(
'modelName' => '',
'optionName' => '',
'emptyField' => '',
'relationName' => '',
)
Definition at line 8 of file UWrelBelongsTo.php.
The documentation for this class was generated from the following file: