You are here

public function ViewsEmbedDialog::buildSelectViewStep in Views entity embed 8

Same name and namespace in other branches
  1. 2.0.x src/Form/ViewsEmbedDialog.php \Drupal\views_entity_embed\Form\ViewsEmbedDialog::buildSelectViewStep()

Form constructor for the entity selection step.

1 call to ViewsEmbedDialog::buildSelectViewStep()
ViewsEmbedDialog::buildForm in src/Form/ViewsEmbedDialog.php
Form constructor.

File

src/Form/ViewsEmbedDialog.php, line 132

Class

ViewsEmbedDialog
Provides a form to embed URLs.

Namespace

Drupal\views_entity_embed\Form

Code

public function buildSelectViewStep(array &$form, FormStateInterface $form_state, $embed_button) {
  $view_element = $form_state
    ->get('view_element');
  $form['view_name'] = [
    '#type' => 'select',
    '#options' => $this
      ->getViewsOptions($embed_button),
    '#title' => t('Select View'),
    '#required' => TRUE,
    '#default_value' => isset($view_element['data-view-name']) ? $view_element['data-view-name'] : '',
  ];
  $form['actions']['save_modal'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Next'),
    '#button_type' => 'primary',
    // No regular submit-handler. This form only works via JavaScript.
    '#submit' => [],
    '#ajax' => [
      'callback' => '::submitSelectViewStep',
      'event' => 'click',
    ],
    '#attributes' => [
      'class' => [
        'js-button-next',
      ],
    ],
  ];
  return $form;
}