From 82cf0710d4b7a0807d8b53dfe463ef0c07cdce14 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Fri, 3 Jun 2022 15:24:14 +1200 Subject: [PATCH] Fix fatal when going back from MapField due to no dataSource --- CRM/Import/Form/DataSource.php | 5 ++++- CRM/Import/Forms.php | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CRM/Import/Form/DataSource.php b/CRM/Import/Form/DataSource.php index 19fea5947c..a5e53ad43f 100644 --- a/CRM/Import/Form/DataSource.php +++ b/CRM/Import/Form/DataSource.php @@ -63,7 +63,10 @@ abstract class CRM_Import_Form_DataSource extends CRM_Import_Forms { */ public function buildQuickForm() { $config = CRM_Core_Config::singleton(); - + // When we switch to using the DataSource.tpl used by Contact we can remove this in + // favour of the one used by Contact - I was trying to consolidate + // first & got stuck on https://github.com/civicrm/civicrm-core/pull/23458 + $this->add('hidden', 'hidden_dataSource', 'CRM_Import_DataSource_CSV'); $uploadFileSize = CRM_Utils_Number::formatUnitSize($config->maxFileSize . 'm', TRUE); //Fetch uploadFileSize from php_ini when $config->maxFileSize is set to "no limit". diff --git a/CRM/Import/Forms.php b/CRM/Import/Forms.php index c3f3646002..e87bc5acb7 100644 --- a/CRM/Import/Forms.php +++ b/CRM/Import/Forms.php @@ -137,7 +137,10 @@ class CRM_Import_Forms extends CRM_Core_Form { if ($fieldName === 'dataSource') { // Hard-coded handling for DataSource as it affects the contents of // getSubmittableFields and can cause a loop. - return $this->controller->exportValue('DataSource', 'dataSource'); + // Note that the non-contact imports are not currently sharing the DataSource.tpl + // that adds the CSV/SQL options & hence fall back on this hidden field. + // - todo - switch to the same DataSource.tpl for all. + return $this->controller->exportValue('DataSource', 'dataSource') ?? $this->controller->exportValue('DataSource', 'hidden_dataSource'); } $mappedValues = $this->getSubmittableFields(); if (array_key_exists($fieldName, $mappedValues)) { -- 2.25.1