You are here

public function MaestroTemplateBuilderEditTask::cancelForm in Maestro 3.x

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

File

modules/maestro_template_builder/src/Form/MaestroTemplateBuilderEditTask.php, line 43

Class

MaestroTemplateBuilderEditTask
Maestro Template Editor Edit a Task 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,
  ];

  // Remove the session variable for the task being edited.
  $_SESSION['maestro_template_builder']['maestro_editing_task'] = '';
  $response
    ->addCommand(new HtmlCommand('#edit-task-form', $form));
  $response
    ->addCommand(new CloseModalDialogCommand());
  return $response;
}