diff --git a/src/Plugin/Field/FieldFormatter/ViewfieldDefaultFormatter.php b/src/Plugin/Field/FieldFormatter/ViewfieldDefaultFormatter.php index c4b2b14..b0f1a13 100644 --- a/src/Plugin/Field/FieldFormatter/ViewfieldDefaultFormatter.php +++ b/src/Plugin/Field/FieldFormatter/ViewfieldDefaultFormatter.php @@ -35,9 +35,11 @@ public function viewElements(FieldItemListInterface $items, $langcode) { $entity = $item->getEntity(); list($view_name, $view_display) = explode('|', $item->vname, 2); $view = Views::getView($view_name); + $build = $view->buildRenderable($view_display, _viewfield_get_view_args($item->vargs, $entity->getEntityTypeId(), $entity)); $elements[$delta] = array( '#type' => 'viewfield', '#view' => $view, + '#build' => $build, '#access' => $view && $view->access($view_display), '#view_name' => $view_name, '#view_display' => $view_display, diff --git a/viewfield.module b/viewfield.module index 56d3c68..3a929ae 100644 --- a/viewfield.module +++ b/viewfield.module @@ -24,9 +24,7 @@ function viewfield_theme() { */ function viewfield_preprocess_viewfield_formatter_default(&$variables) { $element = $variables['element']; - $view_el = $element['#view']->preview($element['#view_display'], array($element['#view_arguments'])); - $output = render ($view_el); - $variables['output'] = $output; + $variables['output'] = $element['#build']; } /**