示例#1
0
文件: Select.php 项目: qix/phorms
 function validate($value)
 {
     // Pick a comparison function
     $cmpfn = $this->case ? 'strcmp' : 'strcasecmp';
     foreach ($this->options as $option) {
         if ($cmpfn($option->value, $value) == 0) {
             return parent::validate($value);
         }
     }
     if ($this->alternatives) {
         foreach ($this->alternatives as $alternative => $aka) {
             if ($cmpfn($value, $alternative) == 0) {
                 return self::validate($aka);
             }
         }
     }
     return False;
 }
示例#2
0
文件: Group.php 项目: gossi/webform
 public function validate()
 {
     $errors = null;
     try {
         parent::validate();
     } catch (WebformErrors $errs) {
         $errors = $errs;
     }
     if ($this->required && !count($this->getValues())) {
         if (is_null($errors)) {
             $errors = new WebformErrors();
         }
         $e = sprintf($this->getWebform()->getI18n('error/required'), $this->label);
         $this->addError($e);
         $errors->addError($e);
     }
     // throw errors if present
     if (!is_null($errors)) {
         throw $errors;
     }
 }