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 Reply
  • Hi Komal, I went through the scenario. The reason behind your problem definition is simple and functionally correct, when you click on the dynamic link of either form1 or form2 only one form is active and the other form is inactive (stated by your if condition). So the submit button works only on active form. In your case when you selected form1, form1 is activated and then you moved to form2, form2 is active not form1. When you click submit button, the current active form2 is getting validate not form1. I hope this will clarify your doubt. My advise is that if you want all fields validation upon submit, keep all fields directly or fields in sections in a single form.

Children