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; }
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; } }