String Field Type
Description:
The string
field type provides a single-line text input for users to enter short pieces of text. It is suitable for capturing names, titles, short descriptions, or any input that fits within a single line. This field type allows for quick and straightforward data entry, ensuring consistency and simplicity in the data collected.
Elasticsearch Mapping: keyword
(indexed)
YAML Definition
- name: first_name
type: string
display_name: "First Name"
guidance: "Enter the first name."
required: true
default_value: ""
readonly: false
validation: ""
validation_message: ""
display: "text"
options: []
size: ""
format: ""
symbol: ""
cardinality: ""
item_type: ""
dependent_on: []
formula: ""
cascading_parent_field: ""
cascading_options: []
relation: ""
uif: ""
display_toggle_field: ""
lookup_defaults: {}
Attributes
-
name (string): Required.
The unique identifier for the field. -
type (string): Required.
Must be set tostring
for string fields. -
display_name (string): Optional.
The label displayed to the user in the interface. If not provided, a formatted version ofname
is used. -
guidance (string): Optional.
Instructions or help text for the field, assisting users in understanding what to enter. -
required (boolean): Optional.
Iftrue
, the field must be filled before submission. Default:false
. -
readonly (boolean): Optional.
Iftrue
, the field is displayed as 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
. -
default_value (string): Optional.
The default text displayed when the form is first loaded. -
validation (string): Optional.
Validation rules for the text field, such as regex patterns. -
validation_message (string): Optional.
Custom validation error message to display when validation fails. -
display (string): Optional.
UI display type. Options:text
,select
,radio
,checkbox
,textarea
. -
options (array): Optional.
Available options for select/radio fields. Array of strings. -
size (string): Optional.
Field size specification. -
format (string): Optional.
Format specification for the field. -
symbol (string): Optional.
Symbol or prefix for the field. -
cardinality (string): Optional.
Relationship cardinality (oneToOne, oneToMany, etc.). -
item_type (string): Optional.
Type of items in relationship. -
dependent_on (array): Optional.
Fields this field depends on. Array of field names. -
formula (string): Optional.
Formula for calculated fields. -
cascading_parent_field (string): Optional.
Parent field for cascading options. -
cascading_options (array): Optional.
Cascading option definitions. -
relation (string): Optional.
Related field reference. -
uif (string): Optional.
User interface specification. -
display_toggle_field (string): Optional.
Field that controls display of this field. -
lookup_defaults (object): Optional.
Default values for lookup fields.
Examples
Simple String Field:
- name: first_name
type: string
display_name: "First Name"
required: true
guidance: "Enter the person's first name"
Select Field:
- name: preferred_title
type: string
display: "select"
options: ["Mr.", "Mrs.", "Ms.", "Miss"]
display_name: "Preferred Title"
Textarea Field:
- name: description
type: string
display: "textarea"
display_name: "Description"
guidance: "Provide a detailed description"
Field with Validation:
- name: email_address
type: string
display_name: "Email Address"
guidance: "Enter a valid email address."
required: true
validation: "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"
validation_message: "Please enter a valid email address"
Usage Notes
- User Interaction:
- The string field provides a single-line input for users to enter text.
- Suitable for short inputs like names, titles, or identifiers.
- Display Types:
- text: Standard single-line text input
- select: Dropdown selection (requires
options
array) - radio: Radio button selection (requires
options
array) - checkbox: Checkbox input
- textarea: Multi-line text input
- Validation:
- Use the
validation
attribute to enforce specific input formats or constraints. - Common validation rules include:
- required: Ensures the field is not left empty.
- regex patterns: Uses regular expressions to validate input format.
- email: Validates that the input is a properly formatted email address.
- Use the
- Default Values:
- Use
default_value
to pre-fill the field with a default text. - Helpful for providing placeholders or common defaults.
- Use
- Readonly Fields:
- Setting
readonly
totrue
displays the content without allowing user edits. - Useful for displaying system-generated values or information that should not be modified.
- Setting
- Cascading Options:
- Use
cascading_parent_field
andcascading_options
to create dependent dropdowns. - Options change based on the selection in the parent field.
- Use
- Formulas:
- Use
formula
for calculated fields that derive their value from other fields.
- Use
- Use Cases:
- Names: First name, last name, or full name entries.
- Titles: Titles of cases, tasks, or items.
- Identifiers: Codes, usernames, or short descriptions.
- Contact Information: Email addresses, phone numbers, or addresses.
- Selections: Dropdown choices for categories, statuses, or preferences.
- Internationalization:
- Support input in multiple languages and character sets.
- Be mindful of character limits when dealing with languages that use multi-byte characters.
- Accessibility:
- Ensure that the text field is accessible via keyboard navigation.
- Labels and guidance should be clear for users utilizing assistive technologies.
By incorporating the string
field type into your schema, you provide users with a simple and efficient way to input short pieces of text, enhancing the usability and data integrity of your application.