From 88be9dc2fa0d89d31c5adcf1a259459666d0d989 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Fri, 21 Sep 2018 13:48:35 -0400 Subject: [PATCH] dev/core#391 - Fix saving tags in profile --- CRM/Contact/BAO/Contact.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CRM/Contact/BAO/Contact.php b/CRM/Contact/BAO/Contact.php index 9e4488208c..23b3bd4f16 100644 --- a/CRM/Contact/BAO/Contact.php +++ b/CRM/Contact/BAO/Contact.php @@ -2032,8 +2032,10 @@ ORDER BY civicrm_email.is_primary DESC"; CRM_Contact_BAO_GroupContact::create($params['group'], $contactID, $visibility, $method); } - if (!empty($fields['tag'])) { - CRM_Core_BAO_EntityTag::create($params['tag'], 'civicrm_contact', $contactID); + if (!empty($fields['tag']) && array_key_exists('tag', $params)) { + // Convert comma separated form values from select2 v3 + $tags = is_array($params['tag']) ? $params['tag'] : array_fill_keys(array_filter(explode(',', $params['tag'])), 1); + CRM_Core_BAO_EntityTag::create($tags, 'civicrm_contact', $contactID); } //to add profile in default group -- 2.25.1