Select Field Type

Description:
The select field type provides a dropdown list of predefined options for users to choose from. It simplifies data entry by limiting input to valid selections, ensuring consistency and reducing input errors. This field is ideal for cases where the input value should be one of a set of known options, such as categories, statuses, or predefined responses.


YAML Definition

- name: status
  type: select
  display_name: "Status"
  guidance: "Select the current status of the case."
  required: true
  options:
    - "Open"
    - "In Progress"
    - "Closed"
  default_value: "Open"

Attributes

  • name (string): Required.
    The unique identifier for the field.

  • type (string): Required.
    Must be set to select for select fields.

  • display_name (string): Optional.
    The label displayed to the user in the interface. If not provided, a formatted version of name is used.

  • guidance (string): Optional.
    Instructions or help text for the field, assisting users in making the correct selection.

  • required (boolean): Optional.
    If true, the field must be filled before submission.

  • options (array): Required.
    An array of strings representing the available options for selection.

  • default_value (string): Optional.
    The default selected value when the form is first loaded. Must be one of the values specified in options.

  • readonly (boolean): Optional.
    If true, the field is displayed as read-only and cannot be edited by the user.

  • hidden (boolean): Optional.
    If true, the field is hidden from the user interface.


Example

- name: priority
  type: select
  display_name: "Priority Level"
  guidance: "Select the priority level for this issue."
  required: true
  options:
    - "Low"
    - "Medium"
    - "High"
    - "Critical"
  default_value: "Medium"

In this example:

  • priority: Allows users to select the priority level of an issue.
  • options: Provides the list of possible priority levels.
  • default_value: Sets the default selection to “Medium”.

Usage Notes

  • User Interaction:
    • The select field presents a dropdown menu from which users can choose one option.
    • Only the values specified in the options array are valid inputs.
    • Users cannot enter values outside of the predefined options, ensuring data consistency.
  • Options Attribute:
    • The options attribute is required and must be an array of strings.
    • The order of options in the array determines the order they appear in the dropdown.
    • Ensure that the option values are clear and easily understandable to the user.
  • Default Values:
    • Use default_value to set an initial selection when the form loads.
    • The default_value must match one of the values specified in options.
  • Validation:
    • If required is true, validation should ensure that the user has made a selection before allowing form submission.
    • The field should not accept empty or null values when it is required.
  • Readonly Fields:
    • Setting readonly to true displays the selected value without allowing changes.
    • Useful for displaying a value that should not be modified in certain contexts.
  • Guidance and Labels:
    • Provide a clear display_name to help users understand the purpose of the field.
    • Use the guidance attribute to offer additional instructions or context.
  • Use Cases:
    • Status Selection: Choosing the status of a case, such as “Open”, “Pending”, or “Closed”.
    • Category Assignment: Assigning a case to a category or department.
    • Priority Levels: Indicating the urgency of a task or issue.
  • Internationalization:
    • If your application supports multiple languages, ensure that the options are translated accordingly.
    • Consider using option labels and underlying values if you need to store language-independent codes.
    - name: language
      type: select
      display_name: "Preferred Language"
      options:
        - value: "en"
          label: "English"
        - value: "es"
          label: "Spanish"
        - value: "fr"
          label: "French"
      default_value: "en"
    

    In this case, your application logic should handle the key-value structure when rendering the field.

  • Dynamic Options:
    • If the options need to be dynamic based on other fields or external data, consider implementing logic in your application to populate the options array accordingly.
  • Accessibility:
    • Ensure that the select field is accessible via keyboard navigation.
    • Labels and guidance should be clear for users utilizing assistive technologies.

By incorporating the select field type into your schema, you provide users with a straightforward way to select from predefined options, enhancing data consistency and user experience within your application.


Copyright © 2024 Caseblocks Limited.