From b258d2d16aa4cb32aeb5e14d66163226ac5cf3f6 Mon Sep 17 00:00:00 2001 From: mb Date: Sat, 27 Nov 2021 16:43:36 +0100 Subject: [PATCH 1/2] [#46800] Adding all form fields to 'prepareTaskForSave' --- src/Plugin/EngineTasks/MaestroWebformInheritTask.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Plugin/EngineTasks/MaestroWebformInheritTask.php b/src/Plugin/EngineTasks/MaestroWebformInheritTask.php index 289c06d..7cdccda 100644 --- a/src/Plugin/EngineTasks/MaestroWebformInheritTask.php +++ b/src/Plugin/EngineTasks/MaestroWebformInheritTask.php @@ -85,6 +85,17 @@ public function prepareTaskForSave(array &$form, FormStateInterface $form_state, // The field added in getTaskEditForm, needs to be included here, otherwise it won't be saved. $task['data']['inherit_webform_unique_id'] = $form_state->getValue('inherit_webform_unique_id'); + // If we don't add all the fields from the Inherited Class 'MaestroWebformTask', they won't be saved. + $task['data']['unique_id'] = $form_state->getValue('unique_id'); + $task['data']['webform_machine_name'] = $form_state->getValue('webform_machine_name'); + // Forcing this task to not be modal. + $task['data']['modal'] = 'notmodal'; + $task['data']['skip_webform_handlers'] = $form_state->getValue('skip_webform_handlers'); + $task['data']['webform_nodes_attached_to'] = $form_state->getValue('webform_nodes_attached_to'); + $task['data']['use_nodes_attached'] = $form_state->getValue('use_nodes_attached'); + $task['data']['webform_nodes_attached_variable'] = $form_state->getValue('webform_nodes_attached_variable'); + $task['data']['redirect_to'] = $form_state->getValue('redirect_to'); + $task['data']['show_edit_form'] = $form_state->getValue('show_edit_form'); } /** From c4275f4dda67f9a9726058d60751e1419a5b6a20 Mon Sep 17 00:00:00 2001 From: mb Date: Mon, 29 Nov 2021 12:51:09 +0100 Subject: [PATCH 2/2] [#46800] Added custom field to parent prepareTaskForSave method --- .../EngineTasks/MaestroWebformInheritTask.php | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/Plugin/EngineTasks/MaestroWebformInheritTask.php b/src/Plugin/EngineTasks/MaestroWebformInheritTask.php index 7cdccda..cde3022 100644 --- a/src/Plugin/EngineTasks/MaestroWebformInheritTask.php +++ b/src/Plugin/EngineTasks/MaestroWebformInheritTask.php @@ -82,20 +82,11 @@ public function getTaskEditForm(array $task, $templateMachineName) { * {@inheritDoc} */ public function prepareTaskForSave(array &$form, FormStateInterface $form_state, array &$task) { - - // The field added in getTaskEditForm, needs to be included here, otherwise it won't be saved. + + // Inherit from parent + parent::prepareTaskForSave($form, $form_state, $task); + // Add custom field(s) to the inherited prepareTaskForSave method. $task['data']['inherit_webform_unique_id'] = $form_state->getValue('inherit_webform_unique_id'); - // If we don't add all the fields from the Inherited Class 'MaestroWebformTask', they won't be saved. - $task['data']['unique_id'] = $form_state->getValue('unique_id'); - $task['data']['webform_machine_name'] = $form_state->getValue('webform_machine_name'); - // Forcing this task to not be modal. - $task['data']['modal'] = 'notmodal'; - $task['data']['skip_webform_handlers'] = $form_state->getValue('skip_webform_handlers'); - $task['data']['webform_nodes_attached_to'] = $form_state->getValue('webform_nodes_attached_to'); - $task['data']['use_nodes_attached'] = $form_state->getValue('use_nodes_attached'); - $task['data']['webform_nodes_attached_variable'] = $form_state->getValue('webform_nodes_attached_variable'); - $task['data']['redirect_to'] = $form_state->getValue('redirect_to'); - $task['data']['show_edit_form'] = $form_state->getValue('show_edit_form'); } /**