示例#1
0
 public function validate()
 {
     // get captcha response
     $response = recaptcha_check_answer($this->privateKey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
     // ... check if valid
     if (!$response->is_valid) {
         $this->addError($this->getWebform()->getI18n('//error/recaptcha'));
     }
     // throw errors if present
     if ($this->hasErrors()) {
         $errors = new WebformErrors();
         $errors->addErrors($this->errors);
         throw $errors;
     }
 }
示例#2
0
文件: Area.php 项目: gossi/webform
 /**
  * Validates the receiver
  * 
  * @throws \gossi\webform\WebformErrors
  */
 public function validate()
 {
     $e = new WebformErrors();
     foreach ($this->areas as $area) {
         try {
             $area->validate();
         } catch (WebformErrors $ex) {
             $e->addErrors($ex);
         }
     }
     foreach ($this->controls as $control) {
         try {
             $control->validate();
         } catch (WebformErrors $ex) {
             $e->addErrors($ex);
         }
     }
     if ($e->size()) {
         throw $e;
     }
 }
示例#3
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;
     }
 }