Button Bar Form Element

The Button Bar form element displays one or more buttons that the user can click to perform an action.

Example of a Button Bar form element with two buttons, shown in a viewer

Buttons are used to control form validation and submission. When you configure a button, you specify whether the button validates the user's input and/or submits (exits) the form. When the user clicks the button:

  1. Validation: If the button's Causes Validation checkbox is selected, each form element that has validation configured is validated. If there are errors, the user is prompted to make corrections. When the user clicks the button again, the form is revalidated. The validation cycle is repeated until the form is free of errors.

  2. Submission:

    In either of the following scenarios, Causes Validation must be checked for a submit subworkflow to run.

    • Value: If the button has a Value but not a click event, the submit subworkflow runs (if there is one) and the form is exited. The workflow continues running at the next activity following the Display Form activity.

      or

    • Click Event: If the Button Bar has a click event, the click subworkflow runs. If the click subworkflow contains a Propagate Form Event activity, after the click event completes, the submit subworkflow runs (if there is one) and the form is exited. The workflow continues running at the next activity following the Display Form activity.

Footer Button Bar

The most common use for the Button Bar form element is to submit or cancel the form. When you create a new form in Workflow Designer, the form has a Footer Button Bar with Submit and Cancel buttons. The Submit button validates the user's input and submits (exits) the form. The Cancel button submits the form without validating the user's input. For many forms, the default Footer Button Bar is all you need to handle form validation and submission.

Unlike Button Bars that you add to a form, the Footer Button Bar is always positioned at the very bottom of the form. You cannot delete the Footer Button Bar. If you do not want your form to have a footer, clear the Button Bar's Visible checkbox to hide the Button Bar.

Footer Button Bar, shown in a viewer

Button Bar Properties

The Properties table describes the properties of the Button Bar form element. For information about the properties ofa Button Bar's items, see Properties of Form Element Items.

The type of a property defines what types of values the property can have. Many properties are type string, which means that the property's value is text. Boolean properties can be true or false. Some properties have more than one possible type.

Property names in Workflow Designer's Properties panel are written using the capitalization and spacing of a title. Property names in expressions are valid JavaScript identifiers and start with a lower case letter.

In the table below:

Expressions are case sensitive. When you access a form element property in an expression, you must use the correct capitalization.

Properties of the Button Bar Form Element

Accessible Description

Type: String

Name in Properties Panel: Accessible Description

Name to Use in Expressions: accessibleDescription

An accessible version of the description of the element. The accesible description is not visible on the page; it is hidden.

You can use the Accessible Description property to provide a description that can be used by assistive technologies, such as screen readers.

Buttons

Type: { [key: string]: Item; }

Name in Properties Panel: Buttons

Name to Use in Expressions: items

The buttons in the Button Bar. For information on configuring the buttons, see Configure the Buttons in a Button Bar.

The buttons are stored in an object called items. Each button is a property of the items object. To access the items object:

${Display Form ID}.state.{Element ID}.items

For example:

$form1.state.buttonBar1.items

For more information, see Form Element Items.

Description

Type: String

Name in Properties Panel: Description

Name to Use in Expressions: description

A description of the element. The description appears below the element's title.

You can use the Description property to describe what the element represents or to provide instructions to the user about how to use the element.

You can format the description using Markdown.

Element ID

Type: String

The element's ID, which is used in other form elements and activities to access the element's properties, including the user's input. The ID must be unique across all elements in the form.

You cannot set the value of the Element ID property in an expression—you can only use the value that you configured for it. To use the Element ID property in an expression:

${Display Form ID}.state.{Element ID}.{property name}

For example:

$form1.state.buttonBar1.visible

Enabled

Type: Boolean

Name in Properties Panel: Enabled

Name to Use in Expressions: enabled

Indicates whether the Button Bar element is enabled in the running workflow. When a Button Bar element is enabled, the user can click the buttons. When a Button Bar element is disabled, the user can see the Button Bar element, but cannot interact with it. Disabled elements appear dimmed or shaded in the running workflow.

By default, Button Bar elements are enabled. To disable a Button Bar element, clear the Enabled checkbox. You may want to change the property's value at run time depending on the user's input in a previous form element.

To access the enabled property in an expression:

${Display Form ID}.state.{Element ID}.enabled

For example:

$form1.state.buttonBar1.enabled

error

Type: String | MarkdownRef

Indicates whether an error occurred in the element.

We recommend using the Set Form Element Error and Clear Form Element Error activities to work with errors in form elements.

styleName

Type: String

Indicates the name of the style that will be applied to the element.

To access the styleName property in an expression:

${Display Form ID}.state.{Element ID}.styleName

For example:

$form1.state.buttonBar1.styleName

Title

Type: String

Name in Properties Panel: Title

Name to Use in Expressions: title

The element's title, which appears at the top of the element. By default, the title is blank. You may want to change the title to describe what the element represents in your workflow.

You can format the title using Markdown.

Title Location

Type: String

Name in Properties Panel: Title Location

Name to Use in Expressions: titleLocation

Specifies whether the element's title appears above (default) or beside the element.

The value must be either "above" or "beside".

type

Type: String

The variety of form element. Button Bar elements are type "ButtonBar".

Use the type property to find out the variety of a form element in a form with many elements. Loop through ${Display Form ID}.state, comparing each element to the known form types and performing some action on the elements that meet your type criteria.

To access the type property in an expression:

${Display Form ID}.state.{Element ID}.type

For example:

$form1.state.buttonBar1.type

Visible

Type: Boolean

Name in Properties Panel: Visible

Name to Use in Expressions: visible

Indicates whether the element is visible to the user. By default, Button Bar elements are visible. If you want to hide the element, clear the Visible checkbox. You may want to change the visibility at run time depending on the user's input in a previous form element.

To access the visible property in an expression:

${Display Form ID}.state.{Element ID}.visible

For example:

$form1.state.buttonBar1.visible

Button Bar Events

The following table describes the events associated with the Button Bar form element. As in Workflow Designer, the events are listed in the order that they fire.

Events for the Button Bar Form Element

load

The load event fires when the element finishes loading.

You can use the load event to set one or more of the element's properties at run time. For example, you could set the element's initial value.

click

The click event fires when the user clicks a button in the Button Bar.

You could use the click event in a Clear button to remove the user's entries and reset the form to its initial state.

By default, the built-in submit behavior does not work when the Button Bar has a click event. The built-in submit behavior is to run the submit subworkflow, if there is one, and then exit the form. If you want the built-in submit behavior to work, add a Propagate Form Event activity to the click subworkflow. The Propagate Form Event activity instructs the workflow to perform the submit behavior after the click subworkflow completes.

submit

The submit event fires after the user clicks a button that submits the form and has Causes Validation checked, and all the elements in the form pass validation.

The submit event is your last opportunity to perform custom behavior before exiting the form. You could use the submit subworkflow to log information.

Configure the Buttons in a Button Bar

As part of the configuration of a Button Bar, you must configure the buttons in the Button Bar. There are two ways to do this:

Configure Buttons Manually

If you know exactly how many buttons you want and how you want them labelled, you can define the buttons manually when you configure the Button Bar.

To manually configure the buttons in a Button Bar:

  1. In the Buttons area of the Button Bar's properties, make sure Configure them manually is selected.

  2. Configure a button:

    1. Click the arrow to show the button's properties.

    2. Label: In the Label box, type the text that you want to appear on the button.

    3. Value: If you want the form to submit (exit) when the user clicks the button, enter a value that uniquely identifies this button.

      If you do not want the form to submit when the button is clicked, leave the Value property blank or add a click event with no Propagate Form Event activity.

      You can use the Value property to determine which button was selected. Make sure you use a different value for each button so you can test which button was clicked. Within the Button Bar's events, such as a click event, you can find out which button was clicked using an expression similar to this:

      =$form1.event.value

      Later in the workflow, you can find out which button caused the form to submit using the form's result output, for example:

      =$form1.result

      You can use any text for the button's value, for example, Get Another and 842 are valid values.

      An easy way to configure the value is to repeat the label. For example, a Submit button could have submit as its value and a Cancel button could have cancel as its value.

      If you plan to translate the workflow, you may prefer to use numbers as the values.

      If you use digits for the values of the buttons in a Button Bar (for example, you could give the buttons values 1, 2, 3,...), remember that these are text, not numbers. When you check which button was clicked, you must compare to the text value ("1"), not the numeric value (1). For example, you could use an expression like this as the condition for an If activity the follows the Display Form activity:

      =$form1.result == "1"
    4. Default: Select the Default checkbox if you want this button to be selected in the event that the form is submitted automatically, for example, if the user presses Enter instead of clicking a button.

    5. Causes Validation: Select the Causes Validation checkbox if you want the user's input validated when the user clicks the button. This validates the input in every form element that has validation configured.

  3. Repeat the previous step for each button in the Button Bar. Click Add if you need to add a button.

    You can reorder the buttons in a Button Bar by dragging each button to its new position in the list.

  4. Remove any unconfigured buttons that are left over when you finish the configuration.

    To remove a button, click the arrow to show the button's properties and then click Delete.

Use a Subworkflow to Create Buttons

Workflow Designer provides a Blank template that you can use as the starting point for the subworkflow that creates buttons. Initially, the subworkflow has an Event block and nothing else in it. You will have to create the subworkflow from scratch.

To create the subworkflow, first build a list of form element items, and then use the Set Form Element Items activity to assign the items to the Button Bar.