Skip to content

Commit

Permalink
Update fivalidator.class.php
Browse files Browse the repository at this point in the history
Support JSON errors output.
  • Loading branch information
sepiariver committed Dec 3, 2015
1 parent d62d536 commit aeb1889
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion core/components/formit/model/formit/fivalidator.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ function __construct(FormIt &$formit,array $config = array()) {
'placeholderPrefix' => 'fi.',
'validationErrorBulkTpl' => '<li>[[+error]]</li>',
'validationErrorBulkSeparator' => "\n",
'validationErrorBulkFormatJson' => false,
'validationErrorMessage' => '<p class="error">A form validation error occurred. Please check the values you have entered.</p>',
'use_multibyte' => (boolean)$this->modx->getOption('use_multibyte',null,false),
'trimValuesBeforeValidation' => (boolean)$this->modx->getOption('trimValuesBeforeValidation',$this->formit->config,true),
Expand Down Expand Up @@ -720,7 +721,8 @@ public function processErrors() {
foreach ($this->getRawErrors() as $field => $err) {
$errs[] = str_replace(array('[[+field]]','[[+error]]'),array($field,$err),$bulkErrTpl);
}
$errs = implode($this->getOption('validationErrorBulkSeparator'),$errs);
$formatJson = $this->getOption('validationErrorBulkFormatJson');
$errs = ($formatJson) ? $this->modx->toJSON($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 aeb1889

Please sign in to comment.