示例#1
0
 public function getICrugeFieldValue(ICrugeStoredUser $user, ICrugeField $field)
 {
     $model = CrugeFieldValue::loadModelBy($user->getPrimaryKey(), $field->getPrimaryKey());
     if ($model == null) {
         // lo crea
         $model = new CrugeFieldValue();
         $model->iduser = $user->getPrimaryKey();
         $model->idfield = $field->getPrimaryKey();
         $model->value = "";
         if ($model->save()) {
             return $model;
         } else {
             Yii::log("error creando un nuevo CrugeFieldValue:\n" . "iduser: {$user->getPrimaryKey()}\n" . "idfield: {$field->getPrimaryKey()}\n" . "fieldvalue: {$field->getFieldValue()}\n" . "errorSummary:\n " . CHtml::errorSummary($model) . "\n", "error");
             return null;
         }
     }
     return $model;
 }
示例#2
0
 public function getInputField($model, ICrugeField $field)
 {
     $className = get_class($model);
     $name = $className . "[" . $field->fieldname . "]";
     $htmlOpt = array('id' => $className . "_" . $field->fieldname, 'size' => $field->fieldsize, 'maxlength' => $field->maxlength, 'rows' => 5, 'cols' => $field->fieldsize);
     // caso listas: Listbox
     // se espera que venga cada valor que se pasara al <option></option>
     // venga en la forma "VALUE, TEXT"
     //
     $arOpt = array();
     if ($field->fieldtype == CRUGEFIELDTYPE_LISTBOX) {
         $arOpt = CrugeUtil::explodeOptions($field->predetvalue);
         $htmlOpt['rows'] = null;
         $htmlOpt['cols'] = null;
         $htmlOpt['size'] = null;
         $htmlOpt['maxlength'] = null;
     }
     // estos tipos definidos estan en CrugeUserManager
     switch ($field->fieldtype) {
         case CRUGEFIELDTYPE_TEXTBOX:
             return CHtml::textField($name, $field->getFieldValue(), $htmlOpt) . "\n";
         case CRUGEFIELDTYPE_TEXTAREA:
             return CHtml::textArea($name, $field->getFieldValue(), $htmlOpt) . "\n";
         case CRUGEFIELDTYPE_BOOLEAN:
             return CHtml::checkBox($name, $field->getFieldValue(), $htmlOpt) . "\n";
         case CRUGEFIELDTYPE_LISTBOX:
             return CHtml::dropDownList($name, $field->getFieldValue(), $arOpt, $htmlOpt) . "\n";
     }
     return null;
 }