You are here

public function EntityEmbedDialog::submitStep in Entity Embed 8

Form submission handler to to another step of the form.

Parameters

array $form: The form array.

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

string $step: The next step name, such as 'select', 'review' or 'embed'.

Return value

\Drupal\Core\Ajax\AjaxResponse The ajax response.

3 calls to EntityEmbedDialog::submitStep()
EntityEmbedDialog::submitAndShowEmbed in src/Form/EntityEmbedDialog.php
Submit and show embed step after submit.
EntityEmbedDialog::submitAndShowReview in src/Form/EntityEmbedDialog.php
Submit and show review step after submit.
EntityEmbedDialog::submitAndShowSelect in src/Form/EntityEmbedDialog.php
Submit and show select step after submit.

File

src/Form/EntityEmbedDialog.php, line 684

Class

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

Namespace

Drupal\entity_embed\Form

Code

public function submitStep(array &$form, FormStateInterface $form_state, $step) {
  $response = new AjaxResponse();
  $form_state
    ->set('step', $step);
  $form_state
    ->setRebuild(TRUE);
  $rebuild_form = $this->formBuilder
    ->rebuildForm('entity_embed_dialog', $form_state, $form);
  unset($rebuild_form['#prefix'], $rebuild_form['#suffix']);
  $response
    ->addCommand(new HtmlCommand('#entity-embed-dialog-form', $rebuild_form));
  $response
    ->addCommand(new SetDialogTitleCommand('', $rebuild_form['#title']));
  return $response;
}