You are here

public function CkeditorAbbreviationDialog::submitForm in CKEditor Abbreviation 2.0.x

Parameters

array $form: The form array.

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

Return value

Drupal\Core\Ajax\AjaxResponse

Overrides FormInterface::submitForm

File

src/Form/CkeditorAbbreviationDialog.php, line 83

Class

CkeditorAbbreviationDialog
Provides an abbreviation dialog for text editors.

Namespace

Drupal\ckeditor_abbreviation\Form

Code

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