Add state/country custom field options to search builder
authorColeman Watts <coleman@civicrm.org>
Tue, 5 Aug 2014 16:41:04 +0000 (17:41 +0100)
committerColeman Watts <coleman@civicrm.org>
Wed, 13 Aug 2014 09:24:27 +0000 (10:24 +0100)
CRM/Contact/Form/Search/Builder.php

index e2a88eaded998ac030815779a672b973d8642f03..380d04a2696cb1f24b6df0a52a7de8fc0b65c6ce 100644 (file)
@@ -450,10 +450,14 @@ class CRM_Contact_Form_Search_Builder extends CRM_Contact_Form_Search {
       foreach ($fields['values'] as $field => $info) {
         if (!empty($info['options']) || !empty($info['pseudoconstant']) || !empty($info['option_group_id'])) {
           $options[$field] = $entity;
+          // Hack for when search field doesn't match db field - e.g. "country" instead of "country_id"
           if (substr($field, -3) == '_id') {
             $options[substr($field, 0, -3)] = $entity;
           }
         }
+        elseif (!empty($info['data_type']) && in_array($info['data_type'], array('StateProvince', 'Country'))) {
+          $options[$field] = $entity;
+        }
         elseif (in_array(substr($field, 0, 3), array('is_', 'do_')) || CRM_Utils_Array::value('data_type', $info) == 'Boolean') {
           $options[$field] = 'yesno';
           if ($entity != 'contact') {