You are here

public function EntityEmbedDialog::buildReviewStep in Entity Embed 8

Form constructor for the entity review step.

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.

1 call to EntityEmbedDialog::buildReviewStep()
EntityEmbedDialog::buildForm in src/Form/EntityEmbedDialog.php
Form constructor.

File

src/Form/EntityEmbedDialog.php, line 339

Class

EntityEmbedDialog
Provides a form to embed entities by specifying data attributes.

Namespace

Drupal\entity_embed\Form

Code

public function buildReviewStep(array $form, FormStateInterface $form_state) {

  /** @var \Drupal\Core\Entity\EntityInterface $entity */
  $entity = $form_state
    ->get('entity');
  $form['#title'] = $this
    ->t('Review selected @type', [
    '@type' => $entity
      ->getEntityType()
      ->getSingularLabel(),
  ]);
  $form['selection'] = [
    '#markup' => $entity
      ->label(),
  ];
  $form['actions'] = [
    '#type' => 'actions',
  ];
  $form['actions']['back'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Replace selection'),
    // No regular submit-handler. This form only works via JavaScript.
    '#submit' => [],
    '#ajax' => [
      'callback' => '::submitAndShowSelect',
      'event' => 'click',
    ],
  ];
  $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' => '::submitAndShowEmbed',
      'event' => 'click',
    ],
    '#attributes' => [
      'class' => [
        'js-button-next',
      ],
    ],
  ];
  return $form;
}