I have a plain text field in a content type. When I hit return between paragraphs the line breaks are there and show inside of firebug when I inspect the code. However, the body on the view page doesn't render any line breaks. I looked at the plain text input filter and the convert line breaks filter is checked. When I change to filtered html in the settings form of the body widget it works fine.

Do have to use the filtered HTML setting to get the line breaks converted?

  • Which is the plain text field you are referring to? Is it a field you added, or is it added from a third-party module?
    – apaderno
    May 10, 2011 at 16:57
  • I created a field called 'discription'. Then on the settings form was giving a radio element -- Text processing: Plain text || Filtered text (user selects text format). I left it as Plain text and line breaks are not converted.
    – Adam S
    May 10, 2011 at 17:02

2 Answers 2


When you select "Plain text," you are not setting the field to use the "Plain Text" input format; you are setting the field to change the entered text into plain text.

text_field_formatter_view(), the function that outputs the content of a text field, executes the following code, when the field is set to be shown as plain text:

case 'text_plain':
  foreach ($items as $delta => $item) {
    $element[$delta] = array('#markup' => strip_tags($item['value']));

As you see, the text is passed to strip_tags(), which doesn't convert new-line characters in <p> or <div> tags.


The answer to your question is no, it should not.

But I always want it to and so do my users. For textareas that do not require "fancy" formatting, we have still always wanted line breaks to carry over into the display.

I use this in my theme's template.php to add them to plain_text textarea fields:

 * Implements template_preprocess_field().
function THEMENAME_preprocess_field(&$vars, $hook) {
  // Add line breaks to plain text textareas.
  if (
    // Make sure this is a text_long field type.
    $vars['element']['#field_type'] == 'text_long'
    // Check that the field's format is set to null, which equates to plain_text.
    && $vars['element']['#items'][0]['format'] == null
  ) {
    $vars['items'][0]['#markup'] = nl2br($vars['items'][0]['#markup']);
  • Is this possibly the answer to this question here? drupal.stackexchange.com/questions/38666/… I cannot get line breaks preserved while using plain text format, but other people say they are doing so successfully.
    – blue928
    Aug 1, 2012 at 5:26
  • 1
    Thanks for patch, worked for me which enabled me to get on instead of faffing around with endless debates about whether "plain text" is "plain text" or can be filtered and plain text. yawn Aug 21, 2012 at 10:14

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