コード例 #1
0
 /**
  * Renders form properties utilizing the appropriate
  * @param  CActiveForm   $form     The form we're working with
  * @param  Property Name $property The property name from Reflection
  */
 private function renderProperties(&$form, $property)
 {
     $htmlOptions = array('class' => 'pure-input-2-3');
     $validators = $this->model->getValidators($property->name);
     $stringValidators = $this->model->getStringValidator($property->name, $validators);
     if (in_array('required', $stringValidators)) {
         $htmlOptions['required'] = true;
     }
     echo CHtml::openTag('div', array('class' => 'pure-control-group'));
     if (in_array('boolean', $stringValidators)) {
         $form->toggleButtonRow($this->model, $property->name, $htmlOptions, $validators);
     } else {
         if (in_array('number', $stringValidators) && isset($validators[0]->max) && isset($validators[0]->min)) {
             $form->rangeFieldRow($this->model, $property->name, $htmlOptions, $validators);
         } else {
             if (in_array('number', $stringValidators) && (isset($validators[0]->max) || isset($validators[0]->min))) {
                 $form->numberFieldRow($this->model, $property->name, $htmlOptions, $validators);
             } else {
                 if (in_array('password', $stringValidators)) {
                     echo $form->passwordFieldRow($this->model, $property->name, $htmlOptions, $validators);
                 } else {
                     echo $form->textFieldRow($this->model, $property->name, $htmlOptions, $validators);
                 }
             }
         }
     }
     echo CHtml::closeTag('div');
 }