Skip to content

Commit

Permalink
Update fivalidator.class.php
Browse files Browse the repository at this point in the history
Actually make the JSON thing work?
  • Loading branch information
sepiariver committed Dec 3, 2015
1 parent aeb1889 commit 395257b
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions core/components/formit/model/formit/fivalidator.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -717,12 +717,18 @@ public function _getErrorMessage($field,$parameter,$lexiconKey,array $properties
public function processErrors() {
$this->modx->toPlaceholders($this->getErrors(),$this->config['placeholderPrefix'].'error');
$bulkErrTpl = $this->getOption('validationErrorBulkTpl');
$rawErrs = $this->getRawErrors();
$errs = array();
foreach ($this->getRawErrors() as $field => $err) {
$errs[] = str_replace(array('[[+field]]','[[+error]]'),array($field,$err),$bulkErrTpl);
}
$formatJson = $this->getOption('validationErrorBulkFormatJson');
$errs = ($formatJson) ? $this->modx->toJSON($errs) : implode($this->getOption('validationErrorBulkSeparator'),$errs);
if ($formatJson) {
$errs = '';
$errs = $this->modx->toJSON($rawErrs);
} else {
foreach ($rawErrs as $field => $err) {
$errs[] = str_replace(array('[[+field]]','[[+error]]'),array($field,$err),$bulkErrTpl);
}
$errs = implode($this->getOption('validationErrorBulkSeparator'),$errs);
}
$validationErrorMessage = str_replace('[[+errors]]',$errs,$this->getOption('validationErrorMessage'));
$this->modx->setPlaceholder($this->getOption('placeholderPrefix').'validation_error',true);
$this->modx->setPlaceholder($this->getOption('placeholderPrefix').'validation_error_message',$validationErrorMessage);
Expand Down

0 comments on commit 395257b

Please sign in to comment.