1
0
-1

Say, for example, I have a form that contains a dropdown field called "action" with these values: proceed and back.

I want to be able to disable form validation on all fields if action = back.

I read your tutorial on temporarily disable form validation for record creation. It won't help in my case, because the code executes on form load and at that moment, the value of the action field will be empty. I tried to move the code to store binder, but that doesn't help either.

Any idea?

    CommentAdd your comment...

    2 answers

    1.  
      3
      2
      1

      Hi,

      Yes it's possible. This is the following way which is tested and working fine.

      STEPS:

      1- Create a FormAction element.
      2- Place it on the Form.
      3. Hide the default submit button using css in customHTML element . 

      <style>
      
          #submit {
              display:none;
          }
      
      </style>

      4. In your FormAction plugin, get the value of "action" field, If it equals to "back" , write 

      AppService appService = (AppService) FormUtil.getApplicationContext().getBean("appService");
              FormData updatedFormData = appService.submitForm(form, formData, true);

      ELSE, it should validate the form and just change the last param from true to false which is "ignoreValidation".


      Please, find attached the sample app along with the FormActionButton plugin for your use. The above steps is for your understanding only. The attached app has the requested functionality that you want.


      I hope this will help. Sample App URL: Skip Validation App.zip

      Thank you.

      1. Mustapha Hadid

        Awesome. Thank you!

      CommentAdd your comment...
    2.  
      1
      0
      -1

      Hi

      Maybe you could try using "Visibility Control Rules" in Form Section and have two sets of fields in two sections, 1st with validation rules and the 2nd without any validation rules.

      If the field "action = PROCEED", show the section with fields containing validation. If the "action" = BACK, show the other section with fields without validations.

        CommentAdd your comment...