JsFormValidatorBundle
JsFormValidatorBundle copied to clipboard
Recursive validation has no return value
We have ran into an issue with validation triggering and comparing if the form is valid.
FpJsCustomizeMethods.validate({'recursive': true}) (ie: form.jsFormValidator('validate', {'recursive': true}) will always return false since .FpJsFormElement.validateRecursively() (https://github.com/formapro/JsFormValidatorBundle/blob/master/Resources/public/js/fp_js_validator.js#L47) has no return value when executed on: https://github.com/formapro/JsFormValidatorBundle/blob/master/Resources/public/js/fp_js_validator.js#L244.
I am not sure if this intended behavior or FpJsFormElement.validateRecursively() needs to be patched to return the proper form state.
I noticed the same
Original code
FpJsFormValidator.js:46
this.validateRecursively = function () {
this.validate();
for (var childName in this.children) {
this.children[childName].validateRecursively();
}
};
With this snippet you can fix the recursive validation:
FpJsFormValidator.js:46
this.validateRecursively = function () {
if (!this.validate()) {
return false;
}
for (var childName in this.children) {
if (!this.children[childName].validateRecursively()) {
return false;
}
}
return true;
};