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.

Elasticsearch Mapping: keyword (indexed)


YAML Definition

- name: priority
  type: string
  display: select
  display_name: "Priority"
  default_value: "Medium"
  required: true
  readonly: false
  hidden: false
  guidance: "Select the priority level for this case"
  options:
    - "Low"
    - "Medium"
    - "High"
    - "Critical"
  validation: "required"
  validation_message: "Priority selection is required"

Attributes

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

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

  • display (string): Required.
    Must be set to select, select_multiple, or select_multiple_chips for select display.

  • 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. Default: false.

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

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

  • default_value (string or array): Optional.
    The default selected value(s) when the form is first loaded.

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

  • cardinality (string): Optional.
    For multiple selection fields, specifies multiple to allow multiple selections.

  • validation (string): Optional.
    Validation rules for the select field.

  • validation_message (string): Optional.
    Custom validation error message to display when validation fails.


Examples

Single Choice Select Field:

- name: priority
  type: string
  display: select
  display_name: "Priority"
  default_value: "Medium"
  required: true
  guidance: "Select the priority level for this case"
  options:
    - "Low"
    - "Medium"
    - "High"
    - "Critical"
  validation: "required"
  validation_message: "Priority selection is required"

Multiple Choice Select Field:

- name: tags
  type: string
  display: select_multiple
  display_name: "Tags"
  default_value: []
  required: false
  guidance: "Select one or more tags for this case"
  options:
    - "Bug"
    - "Feature"
    - "Enhancement"
    - "Documentation"
    - "Support"
  cardinality: "multiple"

Multiple Choice with Chips Display:

- name: categories
  type: string
  display: select_multiple_chips
  display_name: "Categories"
  default_value: []
  required: false
  guidance: "Select categories to apply to this case"
  options:
    - "Frontend"
    - "Backend"
    - "Database"
    - "API"
    - "UI/UX"
  cardinality: "multiple"

Readonly Select Field:

- name: status
  type: string
  display: select
  display_name: "Status"
  readonly: true
  default_value: "Active"
  options:
    - "Active"
    - "Inactive"
    - "Pending"
    - "Completed"

Usage Notes

  • Display Types:
    • select: Single choice dropdown (default)
    • select_multiple: Multiple choice dropdown with checkboxes
    • select_multiple_chips: Multiple choice with chip/tag display
  • Options Array:
    • Define available options in the options array.
    • Each option should be a string value.
    • Options are displayed in the order they appear in the array.
  • Multiple Selection:
    • Use display: select_multiple or display: select_multiple_chips for multiple selections.
    • Set cardinality: "multiple" to enable multiple selection behavior.
    • Default value should be an array for multiple selection fields.
  • Default Values:
    • For single selection: Use a string value that matches one of the options.
    • For multiple selection: Use an array of strings that match the options.
  • Required Fields:
    • When required is true, users must make a selection before submission.
    • For multiple selection fields, at least one option must be selected.
  • Readonly Fields:
    • Use readonly for system-managed selections that shouldn’t be changed.
    • Common for status fields or calculated categories.
  • Validation:
    • Use validation to enforce selection requirements.
    • Common validation patterns:
      • "required": Must select at least one option
      • "min:1": Minimum number of selections
      • "max:5": Maximum number of selections
  • Use Cases:
    • Categories: Product categories, case categories, or content classification.
    • Status: Case status, order status, or workflow states.
    • Priority: Priority levels, urgency indicators, or importance ratings.
    • Tags: Content tags, labels, or metadata.
    • Preferences: User preferences, settings, or configuration options.
  • User Experience:
    • Provide clear guidance on what options to select.
    • Consider the number of options - too many can overwhelm users.
    • Use logical grouping for related options.
  • Data Handling:
    • Single selections are stored as strings.
    • Multiple selections are stored as arrays of strings.
    • Ensure consistent option values across your application.
  • Accessibility:
    • Ensure that select fields are keyboard accessible.
    • Provide clear labels that screen readers can interpret.
    • Consider providing search functionality for large option lists.
  • Performance Considerations:
    • Large option lists may impact form performance.
    • Consider pagination or search for extensive option lists.
    • Optimize for common selection patterns.

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 © 2025 Caseblocks Limited.