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 for all the help! Below is the snippet of code i am working on

    a!localVariables(
      local!text1,
      local!buttonTxt,
      {
        a!sectionLayout(
          contents: {
            /*This is the only field for which i have to throw required validation when button A and B are clicked */
            /*and for button x this field should be not required
            Also for each button validate is true because they are validating other fields as well
            */
            a!textField(
              label: "Field 1",
              required: true(),
              value: local!text1,
              saveInto: local!text1
            ),
            a!buttonArrayLayout(
              align: "END",
              buttons: {
                a!buttonWidget(
                  label: "Button X",
                  style: "PRIMARY",
                  value: "ButtonX",
                  saveInto: local!buttonTxt,
                  validate: true(),
                  validationGroup: "GroupX"
                )
              }
            ),
            a!buttonArrayLayout(
              align: "END",
              buttons: {
                a!buttonWidget(
                  label: "Button A",
                  value: "ButtonA",
                  saveInto: local!buttonTxt,
                  submit: true(),
                  /*Submit is true*/
                  validate: true(),
                  validationGroup: "GroupA"
                ),
                a!buttonWidget(
                  label: "Button B",
                  style: "PRIMARY",
                  value: "ButtonB",
                  saveInto: local!buttonTxt,
                  submit: true(),
                  /*Submit is true*/
                  validate: true(),
                  validationGroup: "GroupB"
                )
              }
            )
          }
        )
      }
    )

  • 0
    Certified Lead Developer
    in reply to srishtim0001

    Thanks for providing this - as I mentioned above accidentally in the wrong place, can you provide some further detail as to the behavior you're expecting to see on this form, compared to what behavior you're experiencing?

Reply Children
No Data