form->getId(); //$errorfound = json_encode($this->errorfound, JSON_HEX_TAG|JSON_HEX_APOS|JSON_HEX_QUOT|JSON_HEX_AMP); //$errorsfound = json_encode($this->errorsfound, JSON_HEX_TAG|JSON_HEX_APOS|JSON_HEX_QUOT|JSON_HEX_AMP); echo <<'; errorHTML += ''; jQuery("#$id").append(errorHTML); JS; } public function __construct(array $properties = null) { $this->errorfound = __('The following error was found:', 'accua-form-api'); $this->errorsfound = __('The following @errorsize errors were found:', 'accua-form-api'); $this->configure($properties); } public function setErrorsFound($text = '') { $this->errorsfound = $text; } public function setErrorFound($text = '') { $this->errorfound = $text; } private function parse($errors) { $list = array(); if(!empty($errors)) { $keys = array_keys($errors); $keySize = sizeof($keys); for($k = 0; $k < $keySize; ++$k) $list = array_merge($list, $errors[$keys[$k]]); } return $list; } public function render() { $errors = $this->parse($this->form->getErrors()); if(!empty($errors)) { $size = sizeof($errors); if($size == 1) $format = $this->errorfound; else $format = str_replace('@errorsize', $size, $this->errorsfound); echo '
', $format, '
"; } } public function renderAjaxErrorResponse($return = false) { $errors = $this->parse($this->form->getErrors()); if ($return) { return $errors; } if(!empty($errors)) { header("Content-type: application/json"); echo json_encode(array("errors" => $errors), JSON_HEX_TAG|JSON_HEX_APOS|JSON_HEX_QUOT|JSON_HEX_AMP); } } }