Multiple Validation group on a same field

Certified Senior Developer

Can I have multiple validation groups for the one sail component? 

Considering I have Field A, Field B, and 3 buttons. Field A is mandatory for 2 buttons Button_A and Button_B. How to achieve this?

{
    a!columnsLayout(
      columns: {
        a!columnLayout(
          contents: {
            a!textField(
              label: "Name",
              labelPosition: "ABOVE",
              saveInto: {},
              required: true,
              refreshAfter: "UNFOCUS",
              validationGroup:  
                {
                  "Button_A",
                  "Button_B"
                }
              
            ),
            a!textField(
              label: "Mobile Number",
              labelPosition: "ABOVE",
              saveInto: {},
              required: true(),
              refreshAfter: "UNFOCUS",
              validations: {},
              validationGroup: "Button B"
            )
          }
        ),
        
      }
    ),
    a!buttonArrayLayout(
      buttons: {
        a!buttonWidget(
          label: "Button A",
          style: "NORMAL",
          submit: true(),
          validationGroup: "Button_A"
        ),
        a!buttonWidget(
          label: "Button B",
          style: "NORMAL",
          submit: true(),
          validationGroup: "Button_B"
        ),
        a!buttonWidget(
          label: "Button C",
          style: "NORMAL",
          submit: true(),
          validationGroup: "Button_C"
        )
      },
      align: "START"
    )
}

  Discussion posts and replies are publicly visible

Parents Reply Children
  • +1
    Certified Lead Developer
    in reply to Keerthanakr

    Great to know! Another completely undocumented feature.

    A small test:

    {
      a!columnsLayout(
        columns: {
          a!columnLayout(
            contents: {
              a!textField(
                label: "Text (A)",
                labelPosition: "ABOVE",
                saveInto: {},
                refreshAfter: "UNFOCUS",
                required: true,
                validations: {},
                validationGroup: "A"
              )
            }
          ),
          a!columnLayout(
            contents: {
              a!textField(
                label: "Text (A+B)",
                labelPosition: "ABOVE",
                saveInto: {},
                refreshAfter: "UNFOCUS",
                required: true,
                validations: {},
                validationGroup: "A B"
              )
            }
          ),
          a!columnLayout(
            contents: {
              a!textField(
                label: "Text (B+C)",
                labelPosition: "ABOVE",
                saveInto: {},
                refreshAfter: "UNFOCUS",
                required: true,
                validations: {},
                validationGroup: "B C"
              )
            }
          ),
          a!columnLayout(
            contents: {
              a!textField(
                label: "Text (D)",
                labelPosition: "ABOVE",
                saveInto: {},
                refreshAfter: "UNFOCUS",
                required: true,
                validations: {},
                validationGroup: "D"
              )
            }
          ),
        }
      ),
      a!buttonArrayLayout(
        buttons: {
          a!buttonWidget(
            label: "A",
            style: "OUTLINE",
            validate: true,
            validationGroup: "A"
          ),
          a!buttonWidget(
            label: "B",
            style: "OUTLINE",
            validate: true,
            validationGroup: "B"
          ),
          a!buttonWidget(
            label: "C",
            style: "OUTLINE",
            validate: true,
            validationGroup: "C"
          ),
          a!buttonWidget(
            label: "A+D (Does not work)",
            style: "OUTLINE",
            validate: true,
            validationGroup: "A D"
          ),
        },
        align: "START",
        marginBelow: "NONE"
      ),
    }