コード例 #1
0
ファイル: FloatInput.php プロジェクト: projectesIF/Sirius
 /**
  * Validates the input.
  *
  * @param Zikula_Form_View $view Reference to Zikula_Form_View object.
  *
  * @return void
  */
 public function validate(Zikula_Form_View $view)
 {
     parent::validate($view);
     if (!$this->isValid) {
         return;
     }
     if ($this->text !== '') {
         $this->text = DataUtil::transformNumberInternal($this->text);
         if (!is_numeric($this->text)) {
             $this->setError(__('Error! Invalid number.'));
         }
         $i = $this->text;
         if ($this->minValue !== null && $i < $this->minValue || $this->maxValue !== null && $i > $this->maxValue) {
             if ($this->minValue !== null && $this->maxValue !== null) {
                 $this->setError(__f('Error! Range error. Value must be between %1$s and %2$s.', array($this->minValue, $this->maxValue)));
             } elseif ($this->minValue !== null) {
                 $this->setError(__f('Error! The value must be %s or more.', $this->minValue));
             } elseif ($this->maxValue !== null) {
                 $this->setError(__f('Error! The value must be %s or less.', $this->maxValue));
             }
         }
     }
 }