13

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?

18

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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