Validation message not restricting form from submitting

Hi All

 

I am working on version 17.4.

In my main form, user is given dynamic links such that clicking on any link will direct the user to the corresponding interface.

These interfaces contain required fields. When user is on interface corresponding to link 1 i.e. he clicks on link Form 1 and he clicks on Submit button without entering values in the corresponding required fields; then he gets an error message "A value is required". Now he clicks on link Form 2 and he is diverted to corresponding interface. Here also all fields are required. User enters values in Form 2 interface but still leaves fields in Form 1 blank then user is allowed to submit the form.

This is an unexpected behavior as both interfaces are in one formLayout and since he has not entered values for required fields in Form 1 then he should not be allowed to Submit the form.

Below is code snippet for reference.

 

/* Code for Main Form*/

load(
  local!firstName,
  local!lastName,
  local!emailId,
  local!mobileNo,
  local!categorySelection:1,
  with(
    a!formLayout(
      label:"Details Form",
      contents:{
        a!richTextDisplayField(
        align: "CENTER",
        value: {
          /*Form 1*/
          " | ",
          a!richTextItem(
            style: if(local!categorySelection = 1, "STRONG", "NORMAL"),
            text: "Form 1",
            link: if(local!categorySelection = 1, null, a!dynamicLink(value: 1, saveInto: local!categorySelection))
          ),
          if(local!categorySelection = 1, {" ", a!richTextImage(image: a!documentImage(document: cons!FIL_ICON_SEARCH))}, {}),
          /*Form 2*/
          "| ",
          a!richTextItem(
            style: if(local!categorySelection = 2, "STRONG", "NORMAL"),
            text: "Form 2",
            link: if(local!categorySelection = 2, null, a!dynamicLink(value: 2, saveInto: local!categorySelection))
          ),
          if(local!categorySelection = 2, {" ", a!richTextImage(image: a!documentImage(document: cons!FIL_ICON_SEARCH))}, {}),
          " | "
         }
        ), 
        if(isnull(local!categorySelection),
           {},
           choose(local!categorySelection,
             rule!MYAPP_Form1(
               firstName:local!firstName,
               lastName:local!lastName
             ),
             rule!MYAPP_Form2(
               emailId:local!emailId,
               mobileNo:local!mobileNo
             )
           )
        )
      },
      buttons:a!buttonLayout(
        primaryButtons:a!buttonWidgetSubmit(
          label:"Submit",
          value:"Submit"
        ),
        secondaryButtons:a!buttonWidgetSubmit(
          label:"Cancel",
          value:"Cancel",
          style:"DESTRUCTIVE",
          skipValidatio:true
        )
      )
    )
  )
)



/*Code for rule!MYAPP_Form1*/

with(
  a!sectionLayout(
    contents:{
      a!columnsLayout(
        columns:{
          a!columnLayout(
            contents:{
              a!textField(
                label:"First Name",
                value:ri!firstName,
                saveInto:ri!firstName,
                required:true
              )
            }
          ),
          a!columnLayout(
            contents:{
              a!textField(
                label:"Last Name",
                value:ri!lastName,
                saveInto:ri!lastName,
                required:true
              )
            }
          )
        }
      )
    }
  )
)





/*Code for rule!MYAPP_Form2*/

with(
  a!sectionLayout(
    contents:{
      a!columnsLayout(
        columns:{
          a!columnLayout(
            contents:{
              a!textField(
                label:"Email Id",
                value:ri!emailId,
                saveInto:ri!emailId,
                required:true
              )
            }
          ),
          a!columnLayout(
            contents:{
              a!integerField(
                label:"Mobile No.",
                value:ri!mobileNo,
                saveInto:ri!mobileNo,
                required:true
              )
            }
          )
        }
      )
    }
  )
)

Thanks in advance!!

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer
    Hi 2 things here:

    1. When you to avoid submitting a form when there is a validation presented, then never define skipValidation to true() for button

    2. Out of interest, I would like to say, there is a typo i.e. instead of using skipValidation to have used skipValidatio where n is missing, however this won't add any value in preventing the form from submitting it. But it's better to avoid typos.

    Conclusion: either delete skipValidation or set it to false() to avoid submitting the form when a validation has been presented

    Hope this will help
Reply
  • 0
    Certified Lead Developer
    Hi 2 things here:

    1. When you to avoid submitting a form when there is a validation presented, then never define skipValidation to true() for button

    2. Out of interest, I would like to say, there is a typo i.e. instead of using skipValidation to have used skipValidatio where n is missing, however this won't add any value in preventing the form from submitting it. But it's better to avoid typos.

    Conclusion: either delete skipValidation or set it to false() to avoid submitting the form when a validation has been presented

    Hope this will help
Children