Need to make a field is required for a button which has skipped all the validation including this field.

I have a button which has skipped all rule input field validation on one interface. Right now, I want to get a warning when I click the button without a specific rule input field value. 

I couldn't use validationGroup directly because I have made this specific rule input field is mandatory for one more button on the same interface.

Like the example code below, I want to get a warning "text1 is mandatory" when I click the button1. And text1 and text2 are still mandatory field for button2.

load(
  local!button1,
  local!button2,
  local!text1,
  local!text2,
  a!formLayout(
    firstcolumnContents:{
      a!textfield(
        lable: "text1",
        required: true,
        value: local!text1,
        ssaveInto: local!text1
      )
    },
    secondcolunmContents:{
      a!textfield(
        label: "texx2",
        require: true,
        value: local!text2,
        saveInto: local!text2
      )
    },
    buttons: a!buttonlayout:{
    primaryButton:{
 a!buttonWidegetSubmit(
          label: "button1",
          value: true,
          saveInto: local!button1,
          skipvalidation: true
        ),
        a!buttonWidgetSubmit(
          lable: "button2",
          value: false,
          saveInto: local!button2
        )
      }
    }
  )
)

  Discussion posts and replies are publicly visible

Parents
  • Hello Tony,

    I like most of the suggestions from Mike and Robert which I have used in some complex requirements.

    But for me sounds like you can still achieve this with the validation Group but this "little detail" regarding the validationGroup which allows you to add multiple buttons to the form. Before trying all those restructures I strongly recommend you to try the following logic I modified your code which i think is for a version 16.x

    load(
      local!button1,
      local!button2,
      local!text1,
      local!text2,
      a!formLayout(
        firstColumnContents:{
          a!textfield(
            label: "text1",
            required: true,
            value: local!text1,
            saveInto: local!text1,
    		validationGroup:"button1" /*<<-- NOTE this*/
          )
        },
        secondColumnContents:{
          a!textfield(
            label: "texx2",
            required: true,
            value: local!text2,
            saveInto: local!text2,
            validationGroup:"button1 button2" /*<<-- NOTE this*/
          )
        },
        buttons: a!buttonlayout(
        primaryButton:{
            a!buttonWidegetSubmit(
              label: "button1",
              value: true,
              saveInto: local!button1,
              /*skipvalidation: true*/  /*<<-- NOTE this*/
    
              validationGroup:"button1" /*<<-- NOTE this*/
            ),
            a!buttonWidgetSubmit(
              label: "button2",
              value: false,
              saveInto: local!button2,
    
              validationGroup:"button2" /*<<-- NOTE this*/
            )
          }
        )
      )
    )

    I haven't found it documented for that reason I am not sure if it was deprecated or is beta or what happens. But so far it have solved  the form validations.

    Hope this helps

    Jose 

  • Hi Jose,
    Thank you for your solution. This is a very good way to implement. But when I use validationGroup in one field, there is no asterisk on that field. Customers will not notice that is a mandatory field until they get a error message. I can not implement in this way because of the requirement.
  • Hello Tony,

    That's where the other solutions come to play. Another option is just a simple verbiage to instruct the user.

    Let just try once more to defend the Validation Group, by playing a little with the interfaces

    If you were in newer version i would suggest something like this:
    a!textfield(
    readOnly: true,
    labelPosition: "JUSTIFIED",
    label:"text1",
    value:" ",
    required:true
    ),
    a!textfield(
    required: true,
    value: local!text1,
    saveInto: local!text1,
    validationGroup:"button1" /*<<-- NOTE this*/
    )

    If you don't care about the color of the asterisk
    a!richTextDisplayField(
    value:{a!richTextItem(
    text:"Text *",style:"STRONG"
    )
    }
    ),
    a!textfield(
    required: true,
    value: local!text1,
    saveInto: local!text1,
    validationGroup:"button1" /*<<-- NOTE this*/
    )

    Jose
Reply
  • Hello Tony,

    That's where the other solutions come to play. Another option is just a simple verbiage to instruct the user.

    Let just try once more to defend the Validation Group, by playing a little with the interfaces

    If you were in newer version i would suggest something like this:
    a!textfield(
    readOnly: true,
    labelPosition: "JUSTIFIED",
    label:"text1",
    value:" ",
    required:true
    ),
    a!textfield(
    required: true,
    value: local!text1,
    saveInto: local!text1,
    validationGroup:"button1" /*<<-- NOTE this*/
    )

    If you don't care about the color of the asterisk
    a!richTextDisplayField(
    value:{a!richTextItem(
    text:"Text *",style:"STRONG"
    )
    }
    ),
    a!textfield(
    required: true,
    value: local!text1,
    saveInto: local!text1,
    validationGroup:"button1" /*<<-- NOTE this*/
    )

    Jose
Children
No Data