Submit button help

Hi, 

How can I have a submit button at the last page of my dynamic form? 

I am using local!page to determine the page. Currently, the buttons are a!buttonWidget and saves into my local variable. However, on the last page, I'd like a submit button that submits the from. Please take a look at my code and see what you think. 

load(
  local!page: 1,
  a!formLayout(
    label: "Formname",
    contents: {
      choose(
        local!page,
        rule!CHR_SC_EmployeeDetails(
          lead: ri!employee
        ),
        rule!CHR_SC_EmployeeJobDetails(
          lead: ri!jobInfo
        ),
        rule!CHR_SC_NewEmplyeeDone(
          lead: ""
        )
      )
    },
    buttons: a!buttonLayout(
      primaryButtons: {
        a!buttonWidget(
          label: "Back",
          value: local!page - 1,
          saveInto: local!page,
          style: "NORMAL"
        ),
        a!buttonWidget(
          label: "Next",
          cancelbuttonlabel: "BACK",
          value: local!page + 1,
          saveInto: local!page,
          style: "PRIMARY"
        )
      }
    )
  )
)

  Discussion posts and replies are publicly visible

Parents
  • Hi There,

    If you already know what will be your final/last page number, try below code for button.

    a!buttonWidget(
    label: if(local!page= "MaxValueOfPage(i.e=3)","Submit","Next"),
    submit: if(local!page= "MaxValueOfPage",true(),false()),
    cancelbuttonlabel: "BACK",
    value: if(local!page="MaxValueOfPage",
    local!page ,
    local!page + 1),
    saveInto: local!page,
    style: "PRIMARY"
    )
    Regards,
    Simple
  • Thanks, it worked. Really helped me understand buttons and how to make it dynamic in a page. If you have other suggestions of learning how to use buttons (perhaps other examples) please let me know.
  • 0
    Certified Lead Developer
    in reply to erics171

    For simplicity's sake I'd encourage you to use separate button components for "Next" and "Submit" buttons in your use case.

    Abbreviated, it would be something like this:

    a!buttonWidget(
      label: "Next",
      ...
      showWhen: not(local!isOnLastPage)
    ),
    a!buttonWidget(
      label: "Submit",
      ...
      showWhen: local!isOnLastPage
    )


    In this example, you can store a local variable local!isOnLastPage in such a way that it updates to a value of TRUE when the last page is reached. The benefit to doing it this way is, if you ever update the logic determining how the form tells when the last page is reached, you only need to update the local variable definition and not chase down individual components that used the logic separately.

Reply
  • 0
    Certified Lead Developer
    in reply to erics171

    For simplicity's sake I'd encourage you to use separate button components for "Next" and "Submit" buttons in your use case.

    Abbreviated, it would be something like this:

    a!buttonWidget(
      label: "Next",
      ...
      showWhen: not(local!isOnLastPage)
    ),
    a!buttonWidget(
      label: "Submit",
      ...
      showWhen: local!isOnLastPage
    )


    In this example, you can store a local variable local!isOnLastPage in such a way that it updates to a value of TRUE when the last page is reached. The benefit to doing it this way is, if you ever update the logic determining how the form tells when the last page is reached, you only need to update the local variable definition and not chase down individual components that used the logic separately.

Children
No Data