From: Sunil Pawar Date: Thu, 14 Dec 2017 08:29:45 +0000 (+0530) Subject: profile duplicate field validation for field with primary location type X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=2e74ff5574027b2ce84177b82884ebd7c9b87fd1;p=civicrm-core.git profile duplicate field validation for field with primary location type --- 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]; }