Commit a62afb00 authored by Evgenii Nikitin's avatar Evgenii Nikitin Committed by Timo Kirkkala
Browse files

Issue #3276985 by sinn: The user input should equal the output for the description

parent f537ab6c
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -30,9 +30,16 @@ class LinkDescriptionFormatter extends LinkFormatter {
      $elements[$delta] = [
        '#theme' => 'link_with_description',
        '#link' => $link,
        '#description' => $item->description,
      ];

      if ($item->description) {
        // The description value has no text format assigned to it, so the user
        // input should equal the output, including newlines.
        $elements[$delta]['#description'] = [
          '#type' => 'inline_template',
          '#template' => '{{ value|nl2br }}',
          '#context' => ['value' => $item->description],
        ];
      }
    }
    return $elements;
  }
+9 −1
Original line number Diff line number Diff line
@@ -26,7 +26,15 @@ class LinkSeparateDescriptionFormatter extends LinkSeparateFormatter {
    foreach ($items as $delta => $item) {
      // Alter formatter by displaying the additional description via template.
      $elements[$delta]['#theme'] = 'link_with_description_separate_text_url';
      $elements[$delta]['#description'] = $item->description;
      if ($item->description) {
        // The description value has no text format assigned to it, so the user
        // input should equal the output, including newlines.
        $elements[$delta]['#description'] = [
          '#type' => 'inline_template',
          '#template' => '{{ value|nl2br }}',
          '#context' => ['value' => $item->description],
        ];
      }
    }
    return $elements;
  }