CRM-15919 Address getoptions alternative: "abbreviate" context
authorAndrew Hunt <andrew@aghstrategies.com>
Fri, 6 Feb 2015 04:11:05 +0000 (23:11 -0500)
committerAndrew Hunt <andrew@aghstrategies.com>
Fri, 6 Feb 2015 04:11:05 +0000 (23:11 -0500)
CRM/Core/DAO.php
CRM/Core/PseudoConstant.php

index 6edc424c07333935b657ac7e49a4f66f33d8001e..bb3a8aa10a75ad0f4a8b0f583a6b780fb8e58115 100644 (file)
@@ -2173,6 +2173,7 @@ SELECT contact_id
       'create' => "Options are filtered appropriately for the object being created/updated. Labels are translated.",
       'search' => "Searchable options are returned. Labels are translated.",
       'validate' => "All options are returned, even if they are disabled. Machine names are used in place of labels.",
+      'abbreviate' => "Active options are returned, and labels are replaced with abbreviations.",
     );
     // Validation: enforce uniformity of this param
     if ($context !== NULL && !isset($contexts[$context])) {
index aa6dec652ff5c21fe2c5808e2cb90b3d29175621..979cf9e5b551ff05d48858bc22082215fa4dec16 100644 (file)
@@ -287,6 +287,18 @@ class CRM_Core_PseudoConstant {
         'labelColumn' => CRM_Utils_Array::value('labelColumn', $pseudoconstant),
       );
 
+      if ($context == 'abbreviate') {
+        switch ($fieldName) {
+          case 'state_province_id':
+            $params['labelColumn'] = 'abbreviation';
+            break;
+          case 'country_id':
+            $params['labelColumn'] = 'iso_code';
+            break;
+          default:
+        }
+      }
+
       // Fetch option group from option_value table
       if (!empty($pseudoconstant['optionGroupName'])) {
         if ($context == 'validate') {