From f6635f33ed082f6543bc6d793c68a88a2040b280 Mon Sep 17 00:00:00 2001 From: Andrew Hunt Date: Thu, 5 Feb 2015 23:11:05 -0500 Subject: [PATCH] CRM-15919 Address getoptions alternative: "abbreviate" context --- CRM/Core/DAO.php | 1 + CRM/Core/PseudoConstant.php | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/CRM/Core/DAO.php b/CRM/Core/DAO.php index 6edc424c07..bb3a8aa10a 100644 --- a/CRM/Core/DAO.php +++ b/CRM/Core/DAO.php @@ -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])) { diff --git a/CRM/Core/PseudoConstant.php b/CRM/Core/PseudoConstant.php index aa6dec652f..979cf9e5b5 100644 --- a/CRM/Core/PseudoConstant.php +++ b/CRM/Core/PseudoConstant.php @@ -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') { -- 2.25.1