Text Field Type
Description:
The text
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.
YAML Definition
- name: first_name
type: text
display_name: "First Name"
guidance: "Enter the first name."
required: true
default_value: ""
readonly: false
Attributes
-
name (string): Required.
The unique identifier for the field. -
type (string): Required.
Must be set totext
for text 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_value (string): Optional.
The default text displayed when the form is first loaded. -
readonly (boolean): Optional.
Iftrue
, the field is displayed as read-only and cannot be edited by the user. -
hidden (boolean): Optional.
Iftrue
, the field is hidden from the user interface. -
validation (string): Optional.
Validation rules for the text field, such as minimum or maximum length, or regex patterns.
Example
- name: email_address
type: text
display_name: "Email Address"
guidance: "Enter a valid email address."
required: true
validation: "email"
In this example:
- email_address: Captures the user’s email address.
- validation: Specifies that the input must be in a valid email format.
Usage Notes
- User Interaction:
- The text field provides a single-line input for users to enter text.
- Suitable for short inputs like names, titles, or identifiers.
- Validation:
- Use the
validation
attribute to enforce specific input formats or constraints. - Common validation rules include:
- required: Ensures the field is not left empty.
- max_length: Limits the number of characters allowed.
- pattern: Uses a regular expression to validate the 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
- Guidance and Labels:
- Provide a clear
display_name
to help users understand what to enter. - Use the
guidance
attribute to offer additional instructions or examples.
- Provide a clear
- 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.
- 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 text
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.