Commit 6a8bb2e4 authored by Dries's avatar Dries

Issue #1152216 by sun, jhedstrom: Fixed (Long) text field (textarea) with...

Issue #1152216 by sun, jhedstrom: Fixed (Long) text field (textarea) with 'Default' formatter does not retain newlines.
parent 71176ec3
......@@ -38,7 +38,9 @@ public function viewElements(EntityInterface $entity, $langcode, array $items) {
$elements = array();
foreach ($items as $delta => $item) {
$elements[$delta] = array('#markup' => strip_tags($item['value']));
// The text value has no text format assigned to it, so the user input
// should equal the output, including newlines.
$elements[$delta] = array('#markup' => nl2br(check_plain($item['value'])));
}
return $elements;
......
......@@ -222,7 +222,12 @@ function _text_sanitize($instance, $langcode, $item, $column) {
if (isset($item["safe_$column"])) {
return $item["safe_$column"];
}
return $instance['settings']['text_processing'] ? check_markup($item[$column], $item['format'], $langcode) : check_plain($item[$column]);
if ($instance['settings']['text_processing']) {
return check_markup($item[$column], $item['format'], $langcode);
}
// Escape all HTML and retain newlines.
// @see \Drupal\text\Plugin\field\formatter\TextPlainFormatter
return nl2br(check_plain($item[$column]));
}
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment