Sterc / FormIt

A dynamic form processing Snippet for MODX Revolution
https://docs.modx.com/current/en/extras/formit
33 stars 58 forks source link

Custom validator messages not showing #273

Open Ruslan-Aleev opened 2 years ago

Ruslan-Aleev commented 2 years ago

Bug report

Summary

The documentation (https://docs.modx.com/current/en/extras/formit/formit.validators#custom-validators) has an example of a custom validator:

<?php
$value = (float)$value;
$success = $value > 1000;
if (!$success) {
    // Note how we can add an error to the field here.
    $validator->addError($key,'Not big enough!');
}
return $success;

But when trying to display an error message about the custom validator, nothing is displayed.

[[!+fi.error.fieldName]] (fieldName is the field for validation) returns nothing. At the same time, the messages of standard validators are displayed normally.

Moreover, this is also true for external validators, for example, ReCaptchaV2 (there is a built-in validator that also does not return a lexicon with an error).

Environment

FormIt 4.2.7-pl MODX 2.8.4