Text Field
The Text field type provides a multi-line text area for users to input longer strings of text within the CMS.
Alternative for shorter or rich text
If you need to handle shorter text content, consider using the String field type instead.
If you need rich text formatting, consider using the RichText field type instead.
User Interface
Editor
Multi-line text area for entering longer strings of text. It supports standard text input features like copy-paste, undo-redo, and basic keyboard shortcuts.
A character counter can be displayed if minlength or maxlength option is set, and a user-friendly validation message will appear if the input does not meet the specified length requirements.
Preview
A read-only view of the entered text.
Data Type
A string with possible line breaks (\n characters) representing the entered text. If the required option is set to false and the field is left empty, the value will be an empty string.
Data Validation
- If the
requiredoption is set totrue, the text must not be empty. - If
minlengthand/ormaxlengthoptions are specified, the text length must be within the defined limits. - If the
patternoption is provided, the text must match the specified regular expression pattern.
Options
In addition to the common field options, the Text field supports the following options:
Required Options
widget
- Type:
string - Default:
string
Must be set to text.
Optional Options
default
- Type:
string - Default:
""
The default value for the field when creating a new entry.
minlength
- Type:
integer - Default:
0
Minimum length of the string. This enables character counter in the UI and validation.
maxlength
- Type:
integer - Default:
Infinity
Maximum length of the string. This enables character counter in the UI and validation.
Examples
Basic Text Field
This example shows a simple Text field without any additional options.
- name: description
label: Description
widget: text[[fields]]
name = "description"
label = "Description"
widget = "text"{
"name": "description",
"label": "Description",
"widget": "text"
}{
name: "description",
label: "Description",
widget: "text",
}Output example:
description: "This is a sample description.\nIt can span multiple lines."description = """This is a sample description.
It can span multiple lines."""{
"description": "This is a sample description.\nIt can span multiple lines."
}Default Text Field with Length Restrictions
This example shows a Text field with a default value and length restrictions. The field requires a minimum of 10 characters and allows a maximum of 500 characters.
- name: description
label: Description
widget: text
default: 'Enter your description here.'
minlength: 10
maxlength: 500[[fields]]
name = "description"
label = "Description"
widget = "text"
default = "Enter your description here."
minlength = 10
maxlength = 500{
"name": "description",
"label": "Description",
"widget": "text",
"default": "Enter your description here.",
"minlength": 10,
"maxlength": 500
}{
name: "description",
label: "Description",
widget: "text",
default: "Enter your description here.",
minlength: 10,
maxlength: 500,
}Output example:
description: 'Enter your description here.'description = "Enter your description here."{
"description": "Enter your description here."
}