14

What are the differences between 'Text' and 'Long text' in Drupal 7?

If it is simply database character length, is it better to be cautious and default to using Long text in situations where the domain of possible entered values is not precisely known?

2 Answers 2

21

The differences are laid out in text.module.

  1. text fields are stored as varchar with a maxlength of 255 characters, and their default widget is a simple text input.

  2. long text fields are stored as longtext, with a maximum length of 4 GiB (maximum characters depending on the encoding), and their default widget is a textarea

  3. text with summary fields are like long text fields, except that text processing is enabled by default. That is, summary text can be included along with the main text, and the content will be processed through input filters. The default widget is a "textarea with summary"

Generally, long text and text with summary fields are used for, well, long text— anything longer than a few words or a few dozen characters: body text, lengthy embedding code, data tables, and so on. Ordinary text is better suited to short snippets of text: a personal name, a company tagline, a favorite color.

I think it would be rare that your data would be suitable to either type. If you're storing a biography for a user profile, for example, you would have a clear idea as to whether it is expected to be a narrative of several paragraphs or simply a short personal motto.

0

There are three more types of text that a text field can be set for:

  1. Text plain (stored as varchar)

  2. Text plain long (stored as longtext)

Use these for the most secure outward facing fields. Plain text provides a secure, generic text format that can be used by all roles, including an anonymous user. It has no html formatting tags whatsoever (no bold, no italic, ...)

  1. List (Text)

List text is for key|label lists, as described in Drupal 7 documentation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.