dev/core#391 - Fix saving tags in profile
authorColeman Watts <coleman@civicrm.org>
Fri, 21 Sep 2018 17:48:35 +0000 (13:48 -0400)
committerColeman Watts <coleman@civicrm.org>
Tue, 25 Sep 2018 13:02:44 +0000 (09:02 -0400)
CRM/Contact/BAO/Contact.php

index 9e4488208c0e76eff1f000620f945a3ee5d25eec..23b3bd4f16ba2f6b5d98ea4562ee5b8c7143738d 100644 (file)
@@ -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