From 483a53a8026d47d2feabf6a04fc8599b141d07ae Mon Sep 17 00:00:00 2001 From: "deb.monish" Date: Sat, 6 May 2017 07:31:38 +0530 Subject: [PATCH] CRM-20527: batch data entry does not retain currency --- CRM/Core/BAO/UFGroup.php | 2 +- CRM/Core/Form.php | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CRM/Core/BAO/UFGroup.php b/CRM/Core/BAO/UFGroup.php index df09ffadab..a5944a5994 100644 --- a/CRM/Core/BAO/UFGroup.php +++ b/CRM/Core/BAO/UFGroup.php @@ -2162,7 +2162,7 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) CRM_Contribute_Form_SoftCredit::addPCPFields($form, "[$rowNumber]"); } elseif ($fieldName == 'currency') { - $form->addCurrency($name, $title, $required); + $form->addCurrency($name, $title, $required, NULL, FALSE, FALSE); } elseif ($fieldName == 'contribution_page_id') { $form->add('select', $name, $title, diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index ca76c918fd..8fb7be9b9e 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -1790,13 +1790,15 @@ class CRM_Core_Form extends HTML_QuickForm_Page { * @param bool $required * @param string $defaultCurrency * @param bool $freezeCurrency + * @param bool $setDefaultCurrency */ public function addCurrency( $name = 'currency', $label = NULL, $required = TRUE, $defaultCurrency = NULL, - $freezeCurrency = FALSE + $freezeCurrency = FALSE, + $setDefaultCurrency = TRUE ) { $currencies = CRM_Core_OptionGroup::values('currencies_enabled'); $options = array('class' => 'crm-select2 eight'); @@ -1812,7 +1814,11 @@ class CRM_Core_Form extends HTML_QuickForm_Page { $config = CRM_Core_Config::singleton(); $defaultCurrency = $config->defaultCurrency; } - $this->setDefaults(array($name => $defaultCurrency)); + // In some case, setting currency field by default might override the default value + // as encountered in CRM-20527 for batch data entry + if ($setDefaultCurrency) { + $this->setDefaults(array($name => $defaultCurrency)); + } } /** -- 2.25.1