Use metadata for getOptions abbreviation & include currency symbol
[civicrm-core.git] / CRM / Core / PseudoConstant.php
index 96a6a864206a61999e990ee0764bf0d2f69cef15..c53c451d2d3785b9a9739fae6605ccbbed2b1972 100644 (file)
@@ -253,20 +253,6 @@ 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') {
@@ -327,6 +313,12 @@ class CRM_Core_PseudoConstant {
               $params[$nameField] = 'name';
             }
           }
+
+          // Use abbrColum if context is abbreviate
+          if ($context == 'abbreviate' && (in_array('abbreviation', $availableFields) || !empty($pseudoconstant['abbrColumn']))) {
+            $params['labelColumn'] = $pseudoconstant['abbrColumn'] ?? 'abbreviation';
+          }
+
           // Condition param can be passed as an sql clause string or an array of clauses
           if (!empty($params['condition'])) {
             $wheres[] = implode(' AND ', (array) $params['condition']);