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

    As per you earlier suggestion, "My advise is that if you want all fields validation upon submit, keep all fields directly or fields in sections in a single form" :)

    That's what I was saying in my code itself; I have one form i.e. the main form with multiple sections (which are in interfaces rule!MYAPP_Form1 and rule!MYAPP_Form2).

    So as per my understanding of your last post; when I toggle between sections i.e. when I click on Form 1 link or Form 2 link; then only the section in which I am is active and available for the validations to work on. Correct me if there is any gap in my understanding....
Children