Commit 8839879a authored by Jeremiah Davis's avatar Jeremiah Davis
Browse files

Adjust the empty behavior to check for $elements[#items] rather than just...

Adjust the empty behavior to check for $elements[#items] rather than just $elements. This was not functioning as intended due to [#cache] being tagged on to $elements. [#items] appears if there are results for the view or if “Always build output” is enabled on the field display.
parent 6b952ba6
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -93,7 +93,7 @@ class ViewfieldFormatterDefault extends FormatterBase {
   */
  public function view(FieldItemListInterface $items, $langcode = NULL) {
    $elements = parent::view($items, $langcode);
    if (!empty($elements)) {
    if (isset($elements['#items'])) {
      $elements['#theme'] = 'viewfield';
      $elements['#entity'] = $items->getEntity();
      $elements['#entity_type'] = $items->getEntity()->getEntityTypeId();