You are here

public function PluginConfigFormBase::submitForm in Purge 8.3

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 ConfigFormBase::submitForm

File

modules/purge_ui/src/Form/PluginConfigFormBase.php, line 84

Class

PluginConfigFormBase
Provides a base class for (dialog-driven) plugin configuration forms.

Namespace

Drupal\purge_ui\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  if ($this
    ->isDialog($form, $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('#purgedialogform', $form));
    }
    else {
      $this
        ->submitFormSuccess($form, $form_state);
      $response
        ->addCommand(new CloseModalDialogCommand());
      $response
        ->addCommand(new ReloadConfigFormCommand($this->parentId));
    }
    return $response;
  }
  else {
    if (!$form_state
      ->getErrors()) {
      $this
        ->submitFormSuccess($form, $form_state);
    }
  }
  return parent::submitForm($form, $form_state);
}