In some cases, you may want to set a default selection for some fields in your forms. Many fields support default selections when you are using statically-defined data; such is the case with a dropdown field. However, when a field is connected to a data source, the method of specifying a default selection is not clear. This article will walk you through how to specify a default selection for these types of fields.
To begin, create a static data source. We will be using the default Cars example, which contains the information shown below. You can use a Task data source as well; the concepts outlined in this article still apply.
The "Selection" Property
You can specify whether or not an item is selected by default by adding a "selection" property. This is a Boolean value (True/False) that HelloID will use to determine if the associated value should be selected or not.
Let's extend our static data source by adding a property called "selected". We'll set the Ford Mondeo and the Porsche Boxter to "true", and the Tesla to "false". Your data source definition should look like the screenshot below. Save it when you are finished making these changes.
Configure Form Controls
Create a new form, and add the following controls:
- Drop down
Edit each of the controls and connect them to your Cars data source. Set the Value and Text fields to make and model, respectively. Then, enable the Default Selection property, and update the Selection property to your selected field. Your form fields should have data source settings that look much like the screenshots below.
Above: Drop down, multiselect, and radio field settings.
Below: Grid field settings.
Click Switch to editor to get a preview of your form fields. Notice that the drop down, grid, and radio controls all show the Ford Mondeo as the selected value. The multiselect field, however, shows both the Ford Mondeo and the Porsche Boxter. This is because the multiselect field supports multiple default selections, whereas the other controls will only select the first item to have a "True" selection property.