public function MaestroValidityCheck::cancelForm in Maestro 8.2
Same name and namespace in other branches
- 3.x modules/maestro_template_builder/src/Form/MaestroValidityCheck.php \Drupal\maestro_template_builder\Form\MaestroValidityCheck::cancelForm()
File
- modules/
maestro_template_builder/ src/ Form/ MaestroValidityCheck.php, line 35
Class
Namespace
Drupal\maestro_template_builder\FormCode
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,
];
$items = MaestroEngine::performTemplateValidityCheck($form_state
->getValue('template_machine_name'));
if (count($items['failures']) > 0) {
$response
->addCommand(new FireJavascriptCommand('signalValidationRequired', []));
}
else {
$response
->addCommand(new FireJavascriptCommand('turnOffValidationRequired', []));
}
$response
->addCommand(new HtmlCommand('#template-validity-check', $form));
$response
->addCommand(new CloseModalDialogCommand());
return $response;
}