Form
Form widget is used to create forms that are an important part of many websites. This can be registrations forms, feedback forms, order forms, and so on.
Form structurally contains three child elements:
- Default State – contains all form elements.
- Success State – contains the message returned after successful form submission.
- Error State – contains the message returned after failed form submission.
These elements display three possible states of a Form. When a Form is created, it has Default state. This state is used to make major changes in a Form, e.g. add and remove elements, set it styles.
To control a Form in Success or Error state, you need to switch it in the Settings. For more details, see Form and fields states.
When created, a Form contains the following elements:
- Form title
- Name input field
- E-mail input field
- Submit button
In addition to the Form widget, the Elements panel contains individual elements that can be added to a Form.
Input field is used to collect one-line data.
You can use an input field to enter multiple types of data:
- Plain text
- E-mail
- Phone
- Number
- Date
You can select the required data type in the Settings in the right panel in the Type field.
Phone data type assumes an additional setting, Field mask, which allows you to select a template for entering a phone number for different countries.
After selecting a country, the corresponding template appears in the field.
Setting the data type for the Input field allows the user to enter data of the selected type. In the case of incorrect data type, an error will be displayed.
Text Area allows the user to enter multi-line data, such as lengthy messages. It is commonly used to enter comments, reviews, and other long text.
Checkbox is an element that can be used by the user to answer closed (Yes/No) questions. Best used when the user may or may not agree to some condition.
Checkbox allows you to make single- or multiple-choice selections. You can add options in the Settings by clicking on the + button in the List Items section.
You can also delete an option by clicking on -, or swap options by dragging the icon to the left of the name.
You can click on the desired name and enter a new one to change the name of an option.
Radio buttons allows the user to select one out of multiple options.
Just like for Checkboxes, you can add options for Radio Buttons in the Settings.
Select field is a drop-down list that allows to select one or several list items.
By default, there are three options in the select list. You can edit options in the Settings by adding, removing, swapping, and renaming them.
By default, the user can only select one item from the list. To select several items at a time, you need to enable Allow multiple selection option. In this case, the user will be able to select multiple options from the list using Shift or Ctrl.
When clicking the Submit button, all the data entered by the user are sent to the website owner.
Every created Form has the Submit button by default.
You can add any element in a Form, such as an Input field or a Checkbox, to customize the desired functions.
Also, if necessary, you can add ordinary elements or widgets to a Form, for example, a Text with a description or a Div Block for grouping the elements.
Please note that all Form elements are in the Default State block, so new elements must be added to this block.
To add an element to a Form:
- drag and drop the required element into a Form from the Elements panel.
- or select a Form (Default State block) on the Canvas or the Layers tab and click on the name of the required element in the Elements panel.
Form elements can only be added to a Forms block and dragged only within it.
Each form element (except the Submit button) is a group of elements with the following structure:
- Field Label is a text element with a field name that is displayed on a webpage. You can edit text of a Field Label and also remove a Label from the page.
- Field (name depending on the element) is an element of a Form itself, with which the user interacts.
- Error Message is a message that is displayed when there is an error in a field (for example, if a required field is not filled). The error message can be changed by switching the Form state. For more details, see Fields states.
For example, the structure of the Input Group looks like this:
On the Settings tab in the right panel, you can view the options for each element of a Form. These options will vary depending on the element type. For example, an Input field has the Type option and a Checkbox, Radio Buttons and a Select field has the List item option.
All Form fields (except the Submit button) have two parameters:
- Field name is a header transmitted to the data with the form submission.
- Required field, if set, prohibits the user from submitting a form without filling in this field.
Input field and Text Area elements additionally have the Placeholder setting. This setting is used to display a default text that disappears when the user starts typing in a field. This can be a field name or a sample text.
Do not use placeholders as an input field label or help text (for example, “Password must be at least 8 characters long”). Placeholder will not be translated for site visitors using the translation tools and will not be available to screen readers. Also, placeholder disappears when the user starts typing in a field, making it difficult for him to access that information. For these purposes, it is better to use a separate text field.
In the Form Settings you can switch the Form state and the Fields state:
By switching the Form States in the Settings, you can see on the Canvas what a Form looks like in this particular state
- Default State is the default state before the user interacts with a Form.
- Success State is the Form state after its successful submission. Following successful submission there will appear a message that you can change and customize as you wish.
- Error State is the Form state after its unsuccessful submission. Following unsuccessful submission there will appear an error message that you can change and customize as you wish.
To edit the success message for a form:
- select a Form (on the Canvas or the Layers tab).
- in the Settings > Form State, select Success.
- edit the text of the success message on the Canvas.
To edit the error message for a form:
- Select a Form (on the Canvas or the Layers tab).
- in the Settings > Form State, select Error.
- edit the text of the error message on the Canvas.
A form field has two states:
- Default State is the default state before the user interacts with a Form.
- Error State is the field state when errors occur in the course of form submission. Following unsuccessful submission there will appear an error message that you can change and customize as you wish.
To edit the error message for a field:
- Select a Form (on the Canvas or the Layers tab).
- in the Settings > Fields state, select Error.
- edit the text of the error message on the Canvas under the desired element.
By default, a Form inherits the full width of its parent. You can customize the styles for a Form, including size, paddings, margins, element placement, and more. To do this, select a Form on the Canvas or the Layers tab and set the desired styles on the Styles tab.
For example, you can arrange form fields horizontally. To do this:
- Place the Form fields in a new Div block.
- Set the Flex in the Styles, horizontal direction, and alignment.
Also, you can style all Form elements individually. You can set styles for the entire group, for example, by setting paddings or margins. You can also style the label and the element field individually.
For example, you can change the font of the Form header and field labels, the size and placeholder for input fields, the color and size of a button, and so on.
For Input fields, you can replace Field Labels with Placeholder. To do this:
- You must hide the field labels (in the label element settings in the Display section) or remove the label element from the Canvas.
- Set Placeholder in the Input field settings.
By default, Checkboxes, Radio Buttons, and Select fields have custom styles, i.e. you can set styles for their elements. In the Form settings, you can enable additional styles options - Apply standard browser styles to Checkbox and Radio Buttons and Apply standard browser styles to Select. In this case, these fields will have browser styles and it will be impossible to customize styles for their states.
To style placeholder:
- Select a Form element on the Canvas (you need to select the element itself, not a group of elements).
- On the Styles tab, in the State section, check Placeholder and set the desired styles for it.
For example, you can change the font size or placeholder color.