Open
Description
I've implemented a function that verify validity of other forms in page,
if the form generated from JSONSchema is valid the Submit button is enabled even if other forms are invalid (the function returns false)
which template:
- [ X ] MaterialDesignFrameworkModule — Material Design
To Reproduce
<json-schema-form #schema_form loadExternalAssets="true" [schema]="jsonSchema" language="it"
framework="material-design" [layout]="formLayout" (onSubmit)="submitForm($event)" [widgets]="myWidgets"
[options]="exampleJsonObject" (isValid)="validFormFn($event)"
(validationErrors)="validationErrorsFn($event)" [debug]="false">
</json-schema-form>
validationErrorsFn(event: any): boolean {
const docFormArray = this.form.get('documentsForm') as FormArray;
let validDocs = true;
if (docFormArray) {
validDocs = docFormArray.valid || false;
}
let eventValid = true;
this.jsonFormError = [];
if (event && typeof event === 'object') {
eventValid = false;
event.forEach((x: any) => {
this.jsonFormError.push(`${x.keyword} - ${x.message}`);
});
}
const validForm = validDocs && this.privacyOk && eventValid;
this.validForm = validForm;
console.log('validForm: ', validForm);
return validForm;
}
validFormFn($event) {
console.log('Called validFormFn from: ', $event.toString());
return this.validForm;
}
Expected behavior
The submit button is disabled
Screenshots
Desktop
- OS: Kubuntu 22.10
- Browser: chrome
- Version Versione 99.0.4844.51 (Build ufficiale) (a 64 bit)
Metadata
Metadata
Assignees
Labels
No labels