renderPreview example

$args = [];
    if ($form_state->getValue('view_args', '') !== '') {
      $args = explode('/', $form_state->getValue('view_args'));
    }

    $user_input = $form_state->getUserInput();
    if ($form_state->get('show_preview') || !empty($user_input['js'])) {
      $form['preview'] = [
        '#weight' => 110,
        '#theme_wrappers' => ['container'],
        '#attributes' => ['id' => 'views-live-preview', 'class' => ['views-live-preview']],
        'preview' => $view->renderPreview($this->displayID, $args),
      ];
    }
    $uri = $view->toUrl('preview-form');
    $uri->setRouteParameter('display_id', $this->displayID);
    $form['#action'] = $uri->toString();

    return $form;
  }

  /** * {@inheritdoc} */
Home | Imprint | This part of the site doesn't use cookies.