You are here

public function ViewsEmbedDialog::buildForm 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::buildForm()

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides FormInterface::buildForm

File

src/Form/ViewsEmbedDialog.php, line 74

Class

ViewsEmbedDialog
Provides a form to embed URLs.

Namespace

Drupal\views_entity_embed\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, EditorInterface $editor = NULL, EmbedButtonInterface $embed_button = NULL) {
  $form_state
    ->set('embed_button', $embed_button);
  $form_state
    ->set('editor', $editor);
  $form['#tree'] = TRUE;
  $form['#attached']['library'][] = 'editor/drupal.editor.dialog';
  $form['#prefix'] = '<div id="views-entity-embed-dialog-form">';
  $form['#suffix'] = '</div>';
  if (!$form_state
    ->get('step')) {
    $this
      ->selectStepsOfForm($form, $form_state, $embed_button);
  }
  if ($form_state
    ->get('step') == 'select_view') {
    $form = $this
      ->buildSelectViewStep($form, $form_state, $embed_button);
  }
  elseif ($form_state
    ->get('step') == 'select_display') {
    $form = $this
      ->buildSelectDisplay($form, $form_state, $embed_button);
  }
  elseif ($form_state
    ->get('step') == 'select_arguments') {
    $form = $this
      ->buildSelectArguments($form, $form_state);
  }
  $form['#attributes']['class'][] = 'views-entity-embed-dialog-step--' . $form_state
    ->get('step');
  return $form;
}