Multi Value Field Type
Description:
The multi_value
field type is used to capture multiple values from a predefined set of options. It allows users to select multiple items from a list, making it suitable for tags, categories, preferences, and any scenario where multiple selections are needed. This field type ensures consistent capture of multi-selection data within your application.
Elasticsearch Mapping: object
with _id
and value
properties
YAML Definition
- name: categories
type: multi_value
display_name: "Categories"
guidance: "Select all applicable categories."
required: false
readonly: false
hidden: false
options: []
display: "checkbox"
Attributes
-
name (string): Required.
The unique identifier for the field. -
type (string): Required.
Must be set tomulti_value
for multi-value fields. -
display_name (string): Optional.
The label displayed in the user interface. If not provided, a formatted version ofname
is used. -
guidance (string): Optional.
Help text or instructions for the field, assisting users in understanding what options to select. -
required (boolean): Optional.
Iftrue
, at least one option must be selected before submission. Default:false
. -
readonly (boolean): Optional.
Iftrue
, the field is read-only and cannot be edited by the user. Default:false
. -
hidden (boolean): Optional.
Iftrue
, the field is hidden from the user interface. Default:false
. -
options (array): Optional.
Available options for selection. Array of strings. -
display (string): Optional.
UI display type. Options:checkbox
,select
. Default:checkbox
.
Examples
Basic Multi-Value Field:
- name: interests
type: multi_value
display_name: "Areas of Interest"
guidance: "Select all areas that interest you"
options: ["Technology", "Sports", "Music", "Travel", "Cooking", "Reading"]
display: "checkbox"
Required Multi-Value Field:
- name: skills
type: multi_value
display_name: "Technical Skills"
guidance: "Select all skills you possess"
required: true
options: ["JavaScript", "Python", "Java", "C++", "SQL", "React", "Node.js"]
display: "checkbox"
Multi-Value with Select Display:
- name: tags
type: multi_value
display_name: "Tags"
guidance: "Add relevant tags to categorize this item"
options: ["Urgent", "High Priority", "Bug", "Feature", "Documentation", "Testing"]
display: "select"
Readonly Multi-Value Field:
- name: assigned_categories
type: multi_value
display_name: "Assigned Categories"
readonly: true
options: ["VIP", "Enterprise", "Premium"]
display: "checkbox"
Usage Notes
- Display Options:
- checkbox: Multiple checkboxes for each option (default).
- select: Multi-select dropdown with checkboxes.
- 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.
- Define available options in the
- Required Fields:
- When
required
istrue
, users must select at least one option. - Useful for ensuring critical categorizations or classifications.
- When
- Readonly Fields:
- Use
readonly
for system-assigned or calculated multi-values. - Common for displaying assigned tags or categories that shouldn’t be changed.
- Use
- Hidden Fields:
- Use
hidden
for programmatically managed multi-values. - Useful for internal flags or system-generated tags.
- Use
- Data Structure:
- Multi-value fields store an array of selected values.
- Each selected value includes an
_id
andvalue
property. - Useful for complex data relationships and filtering.
- Use Cases:
- Tags and Categories: Content categorization, item classification.
- Skills and Competencies: Employee skills, project requirements.
- Preferences: User preferences, notification settings.
- Features: Product features, service offerings.
- Classifications: Priority levels, status categories.
- 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.
- Validation:
- Multi-value fields can validate minimum and maximum selections.
- Ensure required fields have at least one selection.
- Consider business rules for option combinations.
- Performance Considerations:
- Large option lists may impact form performance.
- Consider pagination or search for extensive option lists.
- Optimize for common selection patterns.
- Accessibility:
- Ensure that multi-value fields are keyboard accessible.
- Provide clear labels for screen readers.
- Consider alternative input methods for complex selections.
By incorporating the multi_value
field type into your schema, you provide users with flexible multi-selection capabilities, enhancing the categorization and organization of data within your application.