Overview
The most common form widget is the Single Field widget. This allows you to enter the value for a single field, with slightly different controls based on that field’s data type.
You can change the field used by the widget in the widget’s Edit dialog.
State
Most of the time you’ll want single value widgets to be Editable. If we just want to show the value of the field for reference, however, you can change a single value widget’s state to Text Only.
This is what a Text Only single value widget looks like when you’re using a form.
When the widget's state is Hidden it disappears from the form entirely. When it's Disabled it looks the same as Editable except it's grayed out and its value can't be changed.
A widget's state, like many other of its properties, be changed with form actions so you can hide and show, or enable and disable widgets as users are filling out a form.
Type: Single-line or Multi-line
Single value widgets will often be Single-Line, but you can also change their Type to Multi-Line.
This allows forms to collect paragraph-stye text.
Values to show in Dropdown
One of the most useful features of forms is the ability to make data entry easier. The default option for “Values to Show in Dropdown” is None.
This allows the form’s users to type any value they want into a field that looks like this.
If we choose “Other Record Values”, the “Allow Typing New Values” is checked by default.
This allows users to type in any value as before, but it also suggests existing values in the dataset that match what they’ve typed. This can save a lot of time during data entry.
We can also uncheck “Allow Typing New Values” when showing “Other Record Values”. Users will then see a simple dropdown list of options they can choose.
When you choose to show “Specific Values”, the person building the form chooses ahead of time what values will appear. Here we’ve entered three specific companies that users can choose from, and “Allow Typing New Values” is unchecked.
The form will show our three companies in a dropdown list.
You can also check “Allow Typing New Values” when showing “Specific Values”. This will suggest the three companies in a dropdown list, but also allow users to type in something else.
Specific value labels are helpful for showing text labels on the forms that correspond to underlying numerical values.
This allows people to choose one value in a dropdown while another value is saved in the dataset.
Input Validation
Another important feature of forms single value widgets is input validation. By default, input is optional. You can also set validation to Input is Required. This means users will have to enter some value for the field.
You can set a minimum length of content. Here we’re saying users must type at least 5 characters.
You can set a maximum length. Here we’re saying users must type 20 or fewer characters.
You can also set both minimum and maximum lengths.
Finally, you can choose custom form validation and enter a regular expression. In this example we’re requiring the input to match any email address from the domains yahoo.com, hotmail.com, and gmail.com.
This regular expression is for US social security numbers that accepts either a format of 123-45-6789 or 123456789.
^(?:\d{3}-\d{2}-\d{4}|\d{9})$
There are resources across the web to help you learn how to make a regular expression to match the text you want. We’ve found that ChatGPT is amazing at building the perfect regular expression. There are also online tools like RegExr that are really handy.
A widget's input validation, like many other of its properties, be changed with form actions so you can, for example, make a field required or optional as users are filling out a form.
Value change actions
You can choose to run one or more of the following actions whenever a user enters something new in a single field widget:
- Save the current record
- Clear fields and start a new record
- Go to a form page
- Change widget state
- Change widget input validation
You can even develop complex AND/OR and IF/ELSE logic to do different actions based on the form's data or what the form user does as they're filling out the form.
This allows you to build forms that change and update as users interact with them.
Linked fields
Single value widgets can behave a little differently when you choose a field from a linked dataset. In this example we’re creating a single value widget for the “Customer” field in the linked Device Sales dataset.
When your form is on the “many” side of a one-to-many linking relationship, you can choose a single value like any other form fields. When your form is on the “one” side of the one-to-many linking relationship, you can choose multiple values from the linked dataset like in the example below.
You can even use single value widgets for datasets in many-to-many linking relationships that involve a third dataset for linking the other two.
For example, let’s say you have an Employees dataset and a Departments dataset. If you want your employees to be able to be in multiple departments, you’d set up an “Employee Departments” dataset with a field linking to the Employees dataset and a field linking to the Department dataset. You could then choose multiple departments in employee forms, and you could choose multiple employees in department forms.