Exemple #1
0
 public function getFormOptions()
 {
     $float_type = array('float', 'decimal');
     if ($this->real_type) {
         if (in_array($this->compile_orm_type, $float_type) !== in_array($this->real_type, $float_type)) {
             $this->throwError("real_type is not match `doctrine:%s` ", $this->real_type, $this->compile_orm_type);
         }
     } else {
         $this->real_type = $this->compile_orm_type;
     }
     $options = parent::getFormOptions();
     return $options;
 }
Exemple #2
0
 public function getFormOptions()
 {
     $options = parent::getFormOptions();
     $options['max'] = $options['attr']['max'];
     $options['min'] = $options['attr']['min'];
     if ($this->_unit) {
         $options['unit'] = array($this->_unit->getPath(), $this->_unit->getDomain());
     }
     if (null !== $this->icon) {
         if (null === $this->_icon) {
             $this->_icon = $this->tr_node->createValue('icon', $this->icon);
         }
         $options['unit_icon'] = array($this->_icon->getPath(), $this->_icon->getDomain());
     }
     if ($this->trans_unit) {
         $options['trans_unit'] = $this->trans_unit;
     }
     if (null !== $this->choices) {
         foreach ($this->choices as $value) {
             if ($value < $options['min']) {
                 $this->throwError("choices value(%s) small than %s", $value, $options['min']);
             } else {
                 if ($value > $options['max']) {
                     $this->throwError("choices value(%s) bigger than %s", $value, $options['max']);
                 }
             }
         }
         $options['choices'] = $this->choices;
     }
     if (null !== $this->choice_code) {
         if ($this->choices) {
             $this->throwError(' can not use choices_code with choices');
         }
         if (false == strpos($this->choice_code, '$')) {
             $options['choices'] = $this->compilePhpCode(sprintf('$this->%s($object)', $this->choice_code));
         } else {
             $options['choices'] = $this->compilePhpCode($this->choice_code);
         }
     }
     if ('integer' === $this->compile_orm_type) {
         $options['attr']['maxlength'] = strlen($options['max']) + 1;
     } else {
         $options['attr']['maxlength'] = strlen($options['max']) + 4;
     }
     if (null !== $this->precision) {
         $options['float_option'] = array('precision' => $this->precision, 'divisor' => $this->divisor, 'grouping' => $this->grouping);
     }
     return $options;
 }