From 2e74ff5574027b2ce84177b82884ebd7c9b87fd1 Mon Sep 17 00:00:00 2001 From: Sunil Pawar Date: Thu, 14 Dec 2017 13:59:45 +0530 Subject: [PATCH] profile duplicate field validation for field with primary location type --- CRM/Core/BAO/UFField.php | 8 +++++++- CRM/UF/Form/Field.php | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CRM/Core/BAO/UFField.php b/CRM/Core/BAO/UFField.php index 10dccc79db..39b40ecec2 100644 --- a/CRM/Core/BAO/UFField.php +++ b/CRM/Core/BAO/UFField.php @@ -207,7 +207,13 @@ class CRM_Core_BAO_UFField extends CRM_Core_DAO_UFField { $ufField->field_type = $params['field_type']; $ufField->field_name = $params['field_name']; $ufField->website_type_id = CRM_Utils_Array::value('website_type_id', $params); - $ufField->location_type_id = CRM_Utils_Array::value('location_type_id', $params); + if (is_null(CRM_Utils_Array::value('location_type_id', $params, ''))) { + // primary location type have NULL value in DB + $ufField->whereAdd("location_type_id IS NULL"); + } + else { + $ufField->location_type_id = CRM_Utils_Array::value('location_type_id', $params); + } $ufField->phone_type_id = CRM_Utils_Array::value('phone_type_id', $params);; if (!empty($params['id'])) { diff --git a/CRM/UF/Form/Field.php b/CRM/UF/Form/Field.php index 485949e88c..5c8f1a3fae 100644 --- a/CRM/UF/Form/Field.php +++ b/CRM/UF/Form/Field.php @@ -551,6 +551,10 @@ class CRM_UF_Form_Field extends CRM_Core_Form { $apiFormattedParams['location_type_id'] = $params['field_name'][2]; } } + elseif ($params['field_name'][2] == 0) { + // 0 is Primary location type + $apiFormattedParams['location_type_id'] = NULL; + } if (!empty($params['field_name'][3])) { $apiFormattedParams['phone_type_id'] = $params['field_name'][3]; } -- 2.25.1