Facing Issue with validation Group and required field.

Certified Senior Developer

I have a requirement where i have a field and 3 buttons. I have to make the field required(validation should come) on click of 2 button and not required (field is not validated)on click of the third button. The third button is having submit as false(). I have tried many ways to accompalish this 

1) Given condition in the "required" property of the field based on button click.

2) On "validationGroup" property i am calling a rule which decides validationGroup depending on button click.

and many more ways i have tried but nothing is working. Just wanted to know the ideal way of accomplishing this scenario?

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer

    Thanks Mike for the reply. The 3rd button validates other fields hence i can't keep the validate property of it as false.

  • I tried implementing this via 'validationGroup' and got a similar functionality working.  The text field 'Field 2' doesn't show the required indicator since it is optional if the user happens to click on Button B.

    a!localVariables(
      local!text1,
      local!text2,
      {
        a!sectionLayout(
          contents: {
            a!textField(
              label: "Field 1",
              required: true(),
              requiredMessage: "Required field validation",
              value: local!text1,
              saveInto: local!text1
            ),
            a!textField(
              label: "Field 2",
              required: true,
              requiredMessage: "Optional field validation",
              validationGroup: "Group_1",
              value: local!text2,
              saveInto: local!text2
            ),
            a!buttonArrayLayout(
              align: "END",
              buttons: {
                a!buttonWidget(
                  label: "Button A",
                  validate: true(),
                  validationGroup: "Group_1"
                ),
                a!buttonWidget(label: "Button B", validate: true())
              }
            )
          }
        )
      }
    )

Reply
  • I tried implementing this via 'validationGroup' and got a similar functionality working.  The text field 'Field 2' doesn't show the required indicator since it is optional if the user happens to click on Button B.

    a!localVariables(
      local!text1,
      local!text2,
      {
        a!sectionLayout(
          contents: {
            a!textField(
              label: "Field 1",
              required: true(),
              requiredMessage: "Required field validation",
              value: local!text1,
              saveInto: local!text1
            ),
            a!textField(
              label: "Field 2",
              required: true,
              requiredMessage: "Optional field validation",
              validationGroup: "Group_1",
              value: local!text2,
              saveInto: local!text2
            ),
            a!buttonArrayLayout(
              align: "END",
              buttons: {
                a!buttonWidget(
                  label: "Button A",
                  validate: true(),
                  validationGroup: "Group_1"
                ),
                a!buttonWidget(label: "Button B", validate: true())
              }
            )
          }
        )
      }
    )

Children