Form Inputs
Form inputs are the individual fields within a form that collect information from site visitors. With the Designer APIs, you can create various types of inputs, configure their properties, and manage their behavior.
Creating Form Inputs
You can create different types of form inputs using the following elementPresets
:
FormTextInput
FormTextarea
FormSelect
FormCheckboxInput
FormRadioInput
It’s a best practice to wrap each input and its corresponding label (e.g. FormBlockLabel
) in a container element, such as a DivBlock
, to keep them organized.
Example
This example demonstrates how to add a new FormTextInput
with a FormBlockLabel
to an existing form.
Form Input Methods
The following methods are available for interacting with form input elements. Note that supported element types may vary by method.
Retrieves the required status of a form input.
Sets the required status of a form input.
Retrieves the name of the input field.
Sets the name of the input field.
Retrieves the type of the input field.
Only supported by FormTextInput
.
Sets the type of the input field.
Only supported by FormTextInput
.
FAQs
Can I set placeholder text on a form input field?
Yes, you can set placeholder text using custom attributes. This overrides any placeholder text configured in the Designer’s Input Field settings.
For example:
Can I set the options for a preset select input field?
No, currently setting the options for a preset select input field isn’t supported via the Designer API.
You can add a select input field with options by using the custom DOM element method to create a select input field with choices as children.
For example:
Can I create a form with the Element Builder?
No, currently only DOM elements can be created with the Element Builder.