Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

validationErrors: submit is enabled even if function return false #319

Open
enriquez73 opened this issue Apr 7, 2022 · 1 comment
Open

Comments

@enriquez73
Copy link

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

2022-04-07_15-01

Desktop

  • OS: Kubuntu 22.10
  • Browser: chrome
  • Version Versione 99.0.4844.51 (Build ufficiale) (a 64 bit)
@sh1nryu
Copy link

sh1nryu commented Dec 6, 2023

hey, I noticed you have tagged your element with #schema_form - I'm wondering are you accessing the form component in your parent component's ts file? if so, how? (I'm trying and failing to!) Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants