You are here

public function BoxoutDialog::submitForm in Boxout 8

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

src/Form/BoxoutDialog.php, line 103

Class

BoxoutDialog
Provides a boxout dialog for text editors.

Namespace

Drupal\boxout\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-boxout-dialog-form', $form));
  }
  else {
    $response
      ->addCommand(new EditorDialogSave($form_state
      ->getValues()));
    $response
      ->addCommand(new CloseModalDialogCommand());
  }
  return $response;
}