You are here

public function MaestroTemplateBuilderAddNew::cancelForm in Maestro 8.2

Same name and namespace in other branches
  1. 3.x modules/maestro_template_builder/src/Form/MaestroTemplateBuilderAddNew.php \Drupal\maestro_template_builder\Form\MaestroTemplateBuilderAddNew::cancelForm()

File

modules/maestro_template_builder/src/Form/MaestroTemplateBuilderAddNew.php, line 48

Class

MaestroTemplateBuilderAddNew
Maestro Template Builder Add New form.

Namespace

Drupal\maestro_template_builder\Form

Code

public function cancelForm(array &$form, FormStateInterface $form_state) {

  // We cancel the modal dialog by first sending down the form's error state as the cancel is a submit.
  // we then close the modal.
  $response = new AjaxResponse();
  $form['status_messages'] = [
    '#type' => 'status_messages',
    '#weight' => -10,
  ];
  $response
    ->addCommand(new HtmlCommand('#template-add-new-form', $form));
  $response
    ->addCommand(new CloseModalDialogCommand());
  return $response;
}