Skip to main content

Form

Rocket 2.0

The Form component builds a form from a list of fields, such as a contact or request form. It checks required fields, emails and numbers, and fires On submit only when every field is valid.

Properties​

Property
Description
Expected Value
TitleHeading shown at the top of the form. Leave it empty to hide it.Text. Default: Contact us
FieldsThe form's fields, as a list of { name, label, type, required, placeholder, options }. type is text, email, number, textarea, select, checkbox or date, and options lists the choices of a select.Array
Default valuesStarting values, as an object of field name to value. Reset returns the form to these values.Object
Submit buttonText on the submit button.Text. Default: Submit
Show reset buttonShows a Reset button next to the submit button.On or off. Default: On
DisableTurns off every field and both buttons.On or off. Default: Off

Additional Actions​

Each of these can be switched on or off, or set with a logical expression by clicking fx.

Property
Description
Expected Value
VisibilityShows or hides the component. Hidden components keep their space unless Collapse when hidden is on.On or off. Default: On
Collapse when hiddenRemoves the hidden component's space, so the components below it move up.On or off. Default: Off
Loading stateShows the component's loading look and blocks interaction, for example while a query runs.On or off. Default: Off

Devices​

Property
Description
Expected Value
Show on desktopShows the component in the desktop layout.On or off. Default: On
Show on mobileShows the component in the mobile layout.On or off. Default: Off

Events​

Add a handler from the Events section of the properties panel. See Event Triggers for the steps.

Event
Description
On submitTriggers when the form is submitted and every field is valid.
On changeTriggers when the user changes any field.
On resetTriggers when the form is reset.

Component Specific Actions (CSA)​

Run these from an event handler with Control Component, or from a RunJS query. See Component Specific Actions.

Action
Description
How To Access
SubmitChecks every field and shows their errors, then fires On submit if all are valid.components.form1.submit()
ResetReturns every field to its default value and clears the errors shown.components.form1.reset()
Set valuesFills fields from an object of field name to value, passed as Values (object). Fields not in the object keep their values.components.form1.setValues("")
Set visibilityShows the component when true, hides it when false.components.form1.setVisibility(false)
Set disableDisables the component when true, enables it when false.components.form1.setDisable(false)
Set loadingTurns the loading state on with true, off with false.components.form1.setLoading(false)

Exposed Variables​

Variable
Description
How To Access
titleHeading shown at the top of the form. Leave it empty to hide it.{{components.form1.title}}
fieldsThe form's fields, as a list of { name, label, type, required, placeholder, options }. type is text, email, number, textarea, select, checkbox or date, and options lists the choices of a select.{{components.form1.fields}}
defaultValuesStarting values, as an object of field name to value. Reset returns the form to these values.{{components.form1.defaultValues}}
submitLabelText on the submit button.{{components.form1.submitLabel}}
showResetShows a Reset button next to the submit button.{{components.form1.showReset}}
disabledTurns off every field and both buttons.{{components.form1.disabled}}
dataCurrent values of the form, as an object of field name to value.{{components.form1.data}}
isValidtrue when every field passes its checks.{{components.form1.isValid}}
errorsError message for each invalid field, keyed by field name.{{components.form1.errors}}
isVisibleWhether the component is visible.{{components.form1.isVisible}}
isLoadingWhether the component is in its loading state.{{components.form1.isLoading}}
isDisabledWhether the component is disabled.{{components.form1.isDisabled}}

Styles​

Style
Default
ButtonTheme: Brand primary
Field spacing12
Label positionTop
Box shadow0px 0px 0px 0px #00000040

A default that starts with Theme: follows the app's theme until the style is set to another value. See App Themes.