From 142a08b27bde435deecc43dd8470ddbc48e7a1d1 Mon Sep 17 00:00:00 2001 From: demeritcowboy Date: Wed, 29 Nov 2023 16:48:37 -0500 Subject: [PATCH] fix related contact mapping fields --- CRM/Contact/Import/Form/MapField.php | 3 +++ CRM/Import/Form/MapField.php | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CRM/Contact/Import/Form/MapField.php b/CRM/Contact/Import/Form/MapField.php index 583ad04dc0..ce367b544f 100644 --- a/CRM/Contact/Import/Form/MapField.php +++ b/CRM/Contact/Import/Form/MapField.php @@ -82,6 +82,9 @@ class CRM_Contact_Import_Form_MapField extends CRM_Import_Form_MapField { * @throws \Civi\API\Exception\UnauthorizedException */ public function preProcess(): void { + // Don't mess up the fields for related contacts + $this->shouldSortMapperFields = FALSE; + parent::preProcess(); //format custom field names, CRM-2676 $contactType = $this->getContactType(); diff --git a/CRM/Import/Form/MapField.php b/CRM/Import/Form/MapField.php index cf150e0f23..2c8785d424 100644 --- a/CRM/Import/Form/MapField.php +++ b/CRM/Import/Form/MapField.php @@ -31,6 +31,11 @@ abstract class CRM_Import_Form_MapField extends CRM_Import_Forms { */ protected $_mapperFields; + /** + * @var bool + */ + protected $shouldSortMapperFields = TRUE; + /** * Column headers, if we have them * @@ -72,7 +77,9 @@ abstract class CRM_Import_Form_MapField extends CRM_Import_Forms { if (empty($_POST) && count($fieldMappings) > 0 && count($this->getColumnHeaders()) !== count($fieldMappings)) { CRM_Core_Session::singleton()->setStatus(ts('The data columns in this import file appear to be different from the saved mapping. Please verify that you have selected the correct saved mapping before continuing.')); } - asort($this->_mapperFields); + if ($this->shouldSortMapperFields) { + asort($this->_mapperFields); + } parent::preProcess(); } -- 2.25.1