You are here

public function InsertViewDialog::ajaxSubmit in Advanced Insert View 8

Same name and namespace in other branches
  1. 2.0.x src/Form/InsertViewDialog.php \Drupal\insert_view_adv\Form\InsertViewDialog::ajaxSubmit()

An AJAX submit callback to validate the WYSIWYG modal.

Parameters

array $form:

FormStateInterface $form_state:

Return value

AjaxResponse

File

src/Form/InsertViewDialog.php, line 368

Class

InsertViewDialog
Class InsertViewDialog

Namespace

Drupal\insert_view_adv\Form

Code

public function ajaxSubmit(array &$form, FormStateInterface $form_state) {
  $response = new AjaxResponse();
  if (!$form_state
    ->getErrors()) {

    // provide the commands for the widget
    $response
      ->addCommand(new EditorDialogSave($this
      ->getClientValues($form_state)));
    $response
      ->addCommand(new CloseModalDialogCommand());
  }
  else {
    unset($form['#prefix'], $form['#suffix']);
    $form['status_messages'] = [
      '#type' => 'status_messages',
      '#weight' => -10,
    ];
    $response
      ->addCommand(new HtmlCommand(NULL, $form));
  }
  return $response;
}