Commit 8cf38be6 authored by George's avatar George
Browse files

Issue #2996499: Hide when no items to display.

parent e9a77353
Loading
Loading
Loading
Loading
+6 −1
Changes for src/Plugin/Field/FieldFormatter/TaxonomyTermReferenceFormatter.php: 6 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -130,6 +130,11 @@ class TaxonomyTermReferenceFormatter extends EntityReferenceFormatterBase {
   * {@inheritdoc}
   */
  public function viewElements(FieldItemListInterface $items, $langcode) {
    // Don't output anything if there aren't any items.
    if (count($items) < 1) {
      return [];
    }

    $element = [];
    $separator = Html::escape($this->getSetting('separator_option'));
    if ($this->getSetting('element_option') != '- None -') {
@@ -149,7 +154,7 @@ class TaxonomyTermReferenceFormatter extends EntityReferenceFormatterBase {
      $wrapper[1] = '';
    }
    $formatted = '';
    foreach ($this->getEntitiesToView($items, $langcode) as $delta => $entity) {
    foreach ($this->getEntitiesToView($items, $langcode) as $entity) {
      if ($this->getSetting('links_option')) {
        $formatted .= $elementwrap[0] . $entity->toLink()
          ->toString() . $elementwrap[1] . $separator;