diff --git a/src/Fields.php b/src/Fields.php index 14003f11c..05c338cc8 100644 --- a/src/Fields.php +++ b/src/Fields.php @@ -702,13 +702,6 @@ protected function wf_crm_get_fields($var = 'fields') { // Removed due to error, when a custom element is made, revisit. // 'value_callback' => TRUE, ]; - $fields['contribution_is_test'] = [ - 'name' => t('Payment Processor Mode'), - 'type' => 'hidden', - 'expose_list' => TRUE, - 'value' => 0, - 'weight' => 9996, - ]; $fields['contribution_note'] = [ 'name' => t('Contribution Note'), 'type' => 'textarea', diff --git a/src/WebformCivicrmPostProcess.php b/src/WebformCivicrmPostProcess.php index 00407e0cd..cb8b359e8 100644 --- a/src/WebformCivicrmPostProcess.php +++ b/src/WebformCivicrmPostProcess.php @@ -124,6 +124,10 @@ public function validate($form, FormStateInterface $form_state) { } } + if (!empty($this->data['contribution'])) { + $this->data['contribution'][1]['contribution'][1]['is_test'] = (int) $this->node->isTest(); + } + $this->validateThisPage($this->form); if (!empty($this->data['participant']) && !empty($this->data['participant_reg_type'])) { diff --git a/src/WebformCivicrmPreProcess.php b/src/WebformCivicrmPreProcess.php index 6364c89a4..f1f051582 100644 --- a/src/WebformCivicrmPreProcess.php +++ b/src/WebformCivicrmPreProcess.php @@ -76,6 +76,10 @@ function initialize(array &$form, FormStateInterface $form_state, WebformHandler * Set webform default values. */ public function alterForm() { + if (!empty($this->data['contribution'])) { + $this->data['contribution'][1]['contribution'][1]['is_test'] = (int) $this->node->isTest(); + } + // Add css & js $this->addResources(); // Add validation handler