CRM-17534 fix - 'Preferred Communication Methods' don't get saved on Inline Edit
authormonishdeb <monish.deb@webaccessglobal.com>
Wed, 18 Nov 2015 06:38:19 +0000 (12:08 +0530)
committermonishdeb <monish.deb@webaccessglobal.com>
Wed, 18 Nov 2015 06:38:19 +0000 (12:08 +0530)
https://issues.civicrm.org/jira/browse/CRM-17534

CRM/Contact/BAO/Contact.php
tests/phpunit/WebTest/Contact/InlineFieldsEditTest.php

index 03f44cc3bfa76853880f49cea87d7e3b3ea12fca..0d7d7c8e6674e87c57db7d3b050d0371e77452ea 100644 (file)
@@ -157,7 +157,7 @@ class CRM_Contact_BAO_Contact extends CRM_Contact_DAO_Contact {
     }
 
     // Fix for preferred communication method.
-    $prefComm = CRM_Utils_Array::value('preferred_communication_method', $params);
+    $prefComm = CRM_Utils_Array::value('preferred_communication_method', $params, '');
     if ($prefComm && is_array($prefComm)) {
       unset($params['preferred_communication_method']);
       $newPref = array();
@@ -168,16 +168,11 @@ class CRM_Contact_BAO_Contact extends CRM_Contact_DAO_Contact {
         }
       }
 
-      $prefComm = $newPref;
-      if (is_array($prefComm) && !empty($prefComm)) {
-        $prefComm = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($prefComm)) . CRM_Core_DAO::VALUE_SEPARATOR;
-        $contact->preferred_communication_method = $prefComm;
-      }
-      else {
-        $contact->preferred_communication_method = '';
-      }
+      $prefComm = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($newPref)) . CRM_Core_DAO::VALUE_SEPARATOR;
     }
 
+    $contact->preferred_communication_method = $prefComm;
+
     $allNull = $contact->copyValues($params);
 
     $contact->id = CRM_Utils_Array::value('contact_id', $params);
index eecb54b77b9bb2040769fa7bfd0aa36e675ec274..746598d3bdd17c41fe1d7691075a755ba5bf7666 100644 (file)
@@ -163,7 +163,7 @@ class WebTest_Contact_InlineFieldsEditTest extends CiviSeleniumTestCase {
 
     // Edit demographics
     $this->inlineEdit('crm-demographic-content', array(
-      'civicrm_gender_Female_1' => 1,
+      "xpath=//div[@class='crm-clear']/div[1]/div[@class='crm-content']/label[text()='Female']" => true,
       'is_deceased' => 1,
       'birth_date' => 'date: Jan 1 1970',
     ), 'no_open');