You are here

public function MaestroTemplateBuilderCanvas::cancelForm in Maestro 8.2

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

File

modules/maestro_template_builder/src/Form/MaestroTemplateBuilderCanvas.php, line 35

Class

MaestroTemplateBuilderCanvas

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-canvas', $form));
  $response
    ->addCommand(new CloseModalDialogCommand());
  return $response;
}