#991 subtypes not filled in when editing a smart group
authorAndrew West <awest@humanism.org.uk>
Fri, 14 Feb 2020 14:36:59 +0000 (14:36 +0000)
committerGitHub <noreply@github.com>
Fri, 14 Feb 2020 14:36:59 +0000 (14:36 +0000)
https://lab.civicrm.org/dev/core/issues/991

CRM/Contact/Form/Search/Advanced.php

index 6a4127b25aaf0ab90617e721c56d6c883f653415..e25c48fcd4c7684b12bd77249440120a2061a204 100644 (file)
@@ -191,6 +191,14 @@ class CRM_Contact_Form_Search_Advanced extends CRM_Contact_Form_Search {
     ], $defaults);
     $this->normalizeDefaultValues($defaults);
 
+    //991/Subtypes not respected when editing smart group criteria
+    if ($defaults['contact_type'] && !empty($this->_formValues['contact_sub_type'])) {
+      foreach ($this->_formValues['contact_sub_type'] as $subtype) {
+        $basicType = CRM_Contact_BAO_ContactType::getBasicType($subtype);
+        $defaults['contact_type'][$subtype] = $basicType . '__' . $subtype;
+      }
+    }
+    
     if ($this->_context === 'amtg') {
       $defaults['task'] = CRM_Contact_Task::GROUP_ADD;
     }