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