/**
  * Parse each setting
  */
 public function buildFormField($field, $userId)
 {
     $name = 'UserCustomField[' . $field->getKey() . ']';
     $value = UserCustomFieldData::model()->getFieldValue($field, $userId);
     switch ($field->type) {
         case 'textarea':
             echo CHtml::textArea($name, $value, array('rows' => 5, 'class' => 'textbox'));
             break;
         case 'dropdown':
             echo CHtml::dropDownList($name, $value, $this->convertExtraToArray($field->extra), array('class' => 'chosen'));
             break;
         case 'multi':
             echo CHtml::listBox($name, $value ? explode(',', $value) : '', $this->convertExtraToArray($field->extra), array('multiple' => 'multiple', 'class' => 'chosen'));
             break;
         case 'checkbox':
             echo CHtml::checkbox($name, $value, array('class' => ''));
             break;
         case 'yesno':
             echo CHtml::dropDownList($name, $value, array('0' => Yii::t('global', 'No'), '1' => Yii::t('global', 'Yes')), array('class' => 'chosen'));
             break;
         case 'editor':
             Yii::app()->customEditor->getEditor(array('name' => $name, 'value' => $value));
             break;
         case 'text':
         default:
             echo CHtml::textField($name, $value, array('class' => 'textbox'));
             break;
     }
 }
 /**
  * Update field data record
  * 
  */
 public function updateFieldData($fieldId, $userId, $value)
 {
     if (is_array($value) && count($value)) {
         $value = implode(',', $value);
     }
     return UserCustomFieldData::model()->updateAll(array('value' => $value), 'field_id=:field AND user_id=:user', array(':field' => $fieldId, ':user' => $userId));
 }
Beispiel #3
0
 public function getFieldsData($userId)
 {
     $fields = UserCustomField::model()->getFieldsForAdmin();
     $arr = array();
     foreach ($fields as $field) {
         $arr[$field->getKey()] = UserCustomFieldData::model()->getFieldValueForDisplay($field, $userId);
     }
     return $arr;
 }