From 0f77a62576cc1fbfd8a5d59eb9739b8f6c5e5f37 Mon Sep 17 00:00:00 2001 From: monishdeb Date: Fri, 17 Oct 2014 16:12:14 +0530 Subject: [PATCH] CRM-15328 fix - Api ContactType Create Fails for Update https://issues.civicrm.org/jira/browse/CRM-15328 --- CRM/Contact/BAO/ContactType.php | 4 ++-- api/v3/ContactType.php | 15 +++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CRM/Contact/BAO/ContactType.php b/CRM/Contact/BAO/ContactType.php index b9bc73fd24..77657dd27c 100644 --- a/CRM/Contact/BAO/ContactType.php +++ b/CRM/Contact/BAO/ContactType.php @@ -641,10 +641,10 @@ WHERE name = %1"; * @access public * @static */ - static function add($params) { + static function add(&$params) { // label or name - if (empty($params['label'])) { + if (empty($params['id']) && empty($params['label'])) { return; } if (!empty($params['parent_id']) && diff --git a/api/v3/ContactType.php b/api/v3/ContactType.php index 79854ecb26..411e9748c8 100644 --- a/api/v3/ContactType.php +++ b/api/v3/ContactType.php @@ -50,14 +50,17 @@ */ function civicrm_api3_contact_type_create($params) { civicrm_api3_verify_mandatory($params, _civicrm_api3_get_DAO(__FUNCTION__), array('name', 'parent_id')); - if (!array_key_exists('label', $params)) { - $params['label'] = $params['name']; - } - if (!array_key_exists('is_active', $params)) { - $params['is_active'] = TRUE; + + if (empty($params['id'])) { + if (!array_key_exists('label', $params)) { + $params['label'] = $params['name']; + } + if (!array_key_exists('is_active', $params)) { + $params['is_active'] = TRUE; + } + $params['name'] = CRM_Utils_String::munge($params['name']); } - $params['name'] = CRM_Utils_String::munge($params['name']); return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params); } -- 2.25.1