public function MaestroTemplateBuilderEditTask::saveForm in Maestro 8.2
Same name and namespace in other branches
- 3.x modules/maestro_template_builder/src/Form/MaestroTemplateBuilderEditTask.php \Drupal\maestro_template_builder\Form\MaestroTemplateBuilderEditTask::saveForm()
File
- modules/
maestro_template_builder/ src/ Form/ MaestroTemplateBuilderEditTask.php, line 105
Class
- MaestroTemplateBuilderEditTask
- Maestro Template Editor Edit a Task Form.
Namespace
Drupal\maestro_template_builder\FormCode
public function saveForm(array &$form, FormStateInterface $form_state) {
// If we have errors in the form, show those.
if ($form_state
->getErrors()) {
unset($form['#prefix'], $form['#suffix']);
$form['status_messages'] = [
'#type' => 'status_messages',
'#weight' => -10,
];
$response = new AjaxResponse();
// Replaces the form HTML with the validated HTML.
$response
->addCommand(new HtmlCommand('#edit-task-form', $form));
return $response;
}
// Save of the task has already been done in the submit. We now are only responsible for updating the UI and updating the form.
$templateMachineName = $form_state
->getValue('template_machine_name');
$taskID = $form_state
->getValue('task_id');
$task = MaestroEngine::getTemplateTaskByID($templateMachineName, $taskID);
$update = [
'label' => $task['label'],
'taskid' => $task['id'],
'body' => 'placeholder',
'participate_in_workflow_status_stage' => $task['participate_in_workflow_status_stage'],
'workflow_status_stage_number' => $task['workflow_status_stage_number'],
'workflow_status_stage_message' => $task['workflow_status_stage_message'],
];
$response = new AjaxResponse();
$response
->addCommand(new FireJavascriptCommand('maestroUpdateMetaData', $update));
$response
->addCommand(new HtmlCommand('#edit-task-form', $form));
$response
->addCommand(new FireJavascriptCommand('maestroShowSavedMessage', []));
return $response;
}