CRM-20527: batch data entry does not retain currency
authordeb.monish <monish.deb@jmaconsulting.biz>
Sat, 6 May 2017 02:01:38 +0000 (07:31 +0530)
committerdeb.monish <monish.deb@jmaconsulting.biz>
Sat, 6 May 2017 02:01:38 +0000 (07:31 +0530)
CRM/Core/BAO/UFGroup.php
CRM/Core/Form.php

index df09ffadabcbd6054115d8a8d0ce14ceeb367468..a5944a5994a2d6ac199046711099359d1ac4bd2b 100644 (file)
@@ -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,
index ca76c918fd01c838d3dd7fff33a838fdf1d7b9c0..8fb7be9b9eb0e0e8fd9113519195b4f48bec6238 100644 (file)
@@ -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));
+    }
   }
 
   /**