Back to All Videos

Intro to String (Text) Fields

8m 57s

The text field, also commonly referred to as the string field, is perhaps among the most commonly used fields within the CMS. DatoCMS offers you 3 flavors of text fields:

  • Single-line String: A simple text input field for short forms of plain text, such as names, headlines, and button labels.

  • Multi-paragraph Text: A larger text editor for writing content in Markdown, HTML, or Plain text, commonly used for small content blocks or descriptions.

  • Structured Text: A unique and powerful DatoCMS text editor with powerful editing capabilities like slash commands, embeddable blocks, and focus mode, allowing you to focus on creating content with a great UX, and the ability to embed images, videos, maps, and anything else into the field.

Text fields also come with some pretty nifty validations and presentation options.

Aside from marking them as required or unique, the single-line string in particular offers you built-in validations to only accept specific character counts, and patterns, such as URLs, emails, and other RegEx. The single-line string can also be set to present itself to editors as a text input, radio group, or an input selector, aside from the ability to only accept specific inputs.

While the multi-paragraph field isn't intended for things like URLs and Email addresses, it does still offer the same validations to be set as required or match patterns. However, since this field type can be set to accept HTML, there is an added validation to prevent the use of dangerous HTML attributes. Given the extended use-cases for this field, the presentation tab allows to select between a plain text editor, a Markdown editor, or an HTML one, as well as provide some formatting toolbar options on which headings, style options, and link options editors can have.

And finally, the structured text field has some unique new aspects to it. Since this field allows you to both, embed blocks, and link to other models, you have the flexibility to select which blocks can be embedded and which inline records the field can accept. For example, an editor can both, link to an author model, as well as embed a testimonial block into the editor, depending on how much flexibility you give editors. On the presentation tab, you can select what editors can do - between formatting options, allowed heading levels, allowed formattings, and how links and blocks would be treated in the editor.