Choice Fields
A choice field provides several predefined options to choose from, and only one option can be selected.
In the SimpleOne interface, choice fields are displayed in two ways:
Drop-down list
Radio buttons
Create a choice field
This column value can store all kinds of symbols. By default, the string length is 80 symbols. You can change it in the Max length parameter.
When creating a Choice column, in addition to the mandatory fields, you need to fill in the following fields:
- General
- Type Specification
- Default Value
Field | Mandatory | Description |
---|---|---|
Column type | Y | Specify the Choice column type. |
Mandatory | N | Select this checkbox to make the field mandatory (applicable for Choice columns with Choice type = Dropdown with -- None --). |
Field | Mandatory | Description |
---|---|---|
Choice table | N | Specify a table that stores the choice options. |
Choice field | Y | Select a column of the Choice table field that contains choice options. The field appears when the Choice table field is populated. |
Choice type | Y | Define whether the None option is applicable for the field. Available options:
|
Extra attributes | N | Specify additional configurations for the field. For example, enter the following text to apply the radio buttons style to the choice field: choice_decorator=radio The field appears when one of the following options is selected in the Attribute type field:
|
Field | Mandatory | Description |
---|---|---|
Default value | Y/N | Specify the default value for the field. The field is mandatory when the Choice type is Dropdown without --None-- (specify a default value). Verify the field value in the Choice options (sys_choice) dictionary. |
Use dynamic default | N | Select the checkbox if you need to generate the default value dynamically. |
Dynamic default | Y | This field only appears when the Use dynamic default checkbox is selected. Select the script from the Dynamic Default Values (sys_default_value_dynamic) table, so its execution result will be automatically calculated and entered into this field; this value will be the default value for the column specified.
|
Sources for choice options
There are three ways to define a set of choices for the drop-down lists:
- by inheriting values from a parent table (if the current table is a child of another one).
- by creating a set of records for this field in the Choice Options (sys_choice) table.
- by defining a source table and its column in the Type Specification tab.
In the second case, you may need to create a different set of choices if the column is inherited and has predefined options. See Column Override to learn more.
In the third case, the available options are taken from a particular column of the source table. In the example below, the choice table Role contains a column Name. The choice options will be the values of the completed Name fields of the records in this table.
Create a choice option
Before creating a set of options for a particular table and column, ensure that this column is already created. Navigate to System Settings → All Columns.
To create a choice option for a column table, perform the following steps:
- Navigate to the choice column, for which you need to create a set of options.
- In the Related Lists area, select the Choice tab.
- Click New and fill in the fields.
- Click Save or Save and exit to apply the changes.
You can also open the form the following way:
- Navigate to System Settings → Choice Options.
- Click New and fill in the fields.
- Click Save or Save and exit to apply the changes.
Note that in this case, you will need to fill in the Table and Column fields manually.
Choice option form fields
Field | Mandatory | Description |
---|---|---|
Table | Y | Specify the table to which this choice option is related. Select the same table for the translated choice version as for the original one. |
Column | Y | Specify the column to which this choice option is related. Select the same column for the translated choice version as for the original one. |
Title | Y | Type the title of the option. |
Language | Y | Specify the two-symbol name of the language (ru, en, and so on). |
Value | Y | Specify the value of the option. |
Order | Y | Enter the number to define the option order in the choice list. The options are arranged in ascending order. |
A quick way to create several options for the same column is to use Make a copy:
- After saving a choice option, change the Title, Value, Order fields values.
- In the burger menu , select Make a copy. A copy of the current choice option record will be created and saved.
When creating a choice field option, it is recommended to set text values in the Value field to increase code readability. For example, it can be incoming, active, or failed values for Incoming, Active, and Failed choice options, respectively.
As for task states, it makes sense to make values numeric; this can help with selection construction in code.
Choice list translation
To create a translation for the choice options, complete the following steps:
- Navigate to System Settings → Choice Options.
- Open the option for which you need to create a translation.
- Enter the translation in the Title field and specify the language in the Language field.
- Click Make a copy. A copy of the current choice option for the specified language will be created and saved.
Note that the Value field must remain unchanged.
If some choice options are not localized, the choice lists containing untranslated options will display them in English by default, regardless of the current user locale.