From d9ef38cca224a6df54ca5372d5f198a28d25cc62 Mon Sep 17 00:00:00 2001 From: atif-shaikh Date: Tue, 10 Mar 2015 12:46:34 +0530 Subject: [PATCH] CRM-16065 - Custom field set data not being saved if contact has more than one contact sub type https://issues.civicrm.org/jira/browse/CRM-16065 --- CRM/Contact/BAO/ContactType.php | 2 +- CRM/Core/BAO/CustomField.php | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/CRM/Contact/BAO/ContactType.php b/CRM/Contact/BAO/ContactType.php index 24b44f9093..789e7baa55 100644 --- a/CRM/Contact/BAO/ContactType.php +++ b/CRM/Contact/BAO/ContactType.php @@ -933,7 +933,7 @@ WHERE ($subtypeClause)"; * * @return void */ - public function deleteCustomRowsForEntityID($customTable, $entityID) { + public static function deleteCustomRowsForEntityID($customTable, $entityID) { $customTable = CRM_Utils_Type::escape($customTable, 'String'); $query = "DELETE FROM {$customTable} WHERE entity_id = %1"; return CRM_Core_DAO::singleValueQuery($query, array(1 => array($entityID, 'Integer'))); diff --git a/CRM/Core/BAO/CustomField.php b/CRM/Core/BAO/CustomField.php index b869dc34e7..9c090f30cc 100644 --- a/CRM/Core/BAO/CustomField.php +++ b/CRM/Core/BAO/CustomField.php @@ -1583,16 +1583,13 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField { //subtype and basic type $customDataSubType = NULL; if (is_array($customFieldExtend)) { - $customFieldExtend = $customFieldExtend[0]; - } - - if (in_array($customFieldExtend, - CRM_Contact_BAO_ContactType::subTypes() - )) { // This is the case when getFieldsForImport() requires fields // of subtype and its parent.CRM-5143 - $customDataSubType = $customFieldExtend; - $customFieldExtend = CRM_Contact_BAO_ContactType::getBasicType($customDataSubType); + // CRM-16065 - Custom field set data not being saved if contact has more than one contact sub type + $customDataSubType = array_intersect(CRM_Contact_BAO_ContactType::subTypes(), (array) $customFieldExtend); + if (!empty($customDataSubType) && is_array($customDataSubType)) { + $customFieldExtend = array_unique(array_values(CRM_Contact_BAO_ContactType::getBasicType($customDataSubType))); + } } $customFields = CRM_Core_BAO_CustomField::getFields($customFieldExtend, -- 2.25.1