/** * Validate input on EasyForm level * default form validation do nothing. * developers need to override this method to implement their logic * * @return boolean */ protected function validateForm($cleanError = true) { if ($cleanError == true) { $this->m_ValidateErrors = array(); } $this->m_DataPanel->rewind(); while ($this->m_DataPanel->valid()) { /* @var $element Element */ $element = $this->m_DataPanel->current(); if ($element->m_Label) { $elementName = $element->m_Label; } else { $elementName = $element->m_Text; } if ($element->checkRequired() === true && ($element->m_Value == null || $element->m_Value == "")) { $errorMessage = $this->getMessage("FORM_ELEMENT_REQUIRED", array($elementName)); $this->m_ValidateErrors[$element->m_Name] = $errorMessage; //return false; } elseif ($element->m_Value !== null && $element->Validate() == false) { $validateService = BizSystem::getService(VALIDATE_SERVICE); $errorMessage = $this->getMessage("FORM_ELEMENT_INVALID_INPUT", array($elementName, $value, $element->m_Validator)); if ($errorMessage == false) { //Couldn't get a clear error message so let's try this $errorMessage = $validateService->getErrorMessage($element->m_Validator, $elementName); } $this->m_ValidateErrors[$element->m_Name] = $errorMessage; //return false; } $this->m_DataPanel->next(); } if (count($this->m_ValidateErrors) > 0) { throw new ValidationException($this->m_ValidateErrors); return false; } return true; }