You are here

public function EditorLinkDialog::submitForm in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/editor/src/Form/EditorLinkDialog.php \Drupal\editor\Form\EditorLinkDialog::submitForm()
  2. 10 core/modules/editor/src/Form/EditorLinkDialog.php \Drupal\editor\Form\EditorLinkDialog::submitForm()

Form submission handler.

Parameters

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

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

Overrides FormInterface::submitForm

File

core/modules/editor/src/Form/EditorLinkDialog.php, line 73

Class

EditorLinkDialog
Provides a link dialog for text editors.

Namespace

Drupal\editor\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $response = new AjaxResponse();
  if ($form_state
    ->getErrors()) {
    unset($form['#prefix'], $form['#suffix']);
    $form['status_messages'] = [
      '#type' => 'status_messages',
      '#weight' => -10,
    ];
    $response
      ->addCommand(new HtmlCommand('#editor-link-dialog-form', $form));
  }
  else {
    $response
      ->addCommand(new EditorDialogSave($form_state
      ->getValues()));
    $response
      ->addCommand(new CloseModalDialogCommand());
  }
  return $response;
}