CRM-19135: preferred_mail_format not selecting translated labels in international...
authordeb.monish <monish.deb@webaccessglobal.com>
Thu, 28 Jul 2016 09:33:14 +0000 (15:03 +0530)
committerdeb.monish <monish.deb@webaccessglobal.com>
Thu, 28 Jul 2016 09:33:14 +0000 (15:03 +0530)
CRM/Contact/Form/Edit/CommunicationPreferences.php
CRM/Contact/Form/Inline/CommunicationPreferences.php

index 5adefd8d6f12a7b9b27c4c242df942dd3a691a2f..7ab867c8bba313cb2e305a271699b511ff12f3df 100644 (file)
@@ -168,6 +168,9 @@ class CRM_Contact_Form_Edit_CommunicationPreferences {
     if (empty($defaults['preferred_mail_format'])) {
       $defaults['preferred_mail_format'] = 'Both';
     }
+    else {
+      $defaults['preferred_mail_format'] = array_search($defaults['preferred_mail_format'], CRM_Core_SelectValues::pmf());
+    }
 
     //set default from greeting types CRM-4575, CRM-9739
     if ($form->_action & CRM_Core_Action::ADD) {
index f9a6b60075428da1716e6b195c37cebdfa478bf6..e792eb0d00c049120377ac96a5c32287c6dda124 100644 (file)
@@ -64,6 +64,12 @@ class CRM_Contact_Form_Inline_CommunicationPreferences extends CRM_Contact_Form_
       $defaults['preferred_language'] = $config->lcMessages;
     }
 
+    // CRM-19135: where CRM_Core_BAO_Contact::getValues() set label as a default value instead of reserved 'value',
+    // the code is to ensure we always set default to value instead of label
+    if (!empty($defaults['preferred_mail_format'])) {
+      $defaults['preferred_mail_format'] = array_search($defaults['preferred_mail_format'], CRM_Core_SelectValues::pmf());
+    }
+
     if (empty($defaults['communication_style_id'])) {
       $defaults['communication_style_id'] = array_pop(CRM_Core_OptionGroup::values('communication_style', TRUE, NULL, NULL, 'AND is_default = 1'));
     }