From cc6662100de9040ec0245b43fdbbaba0fea3aa17 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Wed, 27 Aug 2014 14:01:40 +0100 Subject: [PATCH] Sort address tokens into an optgroup --- CRM/Utils/Token.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CRM/Utils/Token.php b/CRM/Utils/Token.php index 12e21758e2..0e58f6e12d 100644 --- a/CRM/Utils/Token.php +++ b/CRM/Utils/Token.php @@ -1720,7 +1720,12 @@ class CRM_Utils_Token { // Group by entity else { $split = explode('.', trim($k, '{}')); - $entity = isset($split[1]) ? ucfirst($split[0]) : 'Contact'; + if (isset($split[1])) { + $entity = array_key_exists($split[1], CRM_Core_DAO_Address::export()) ? 'Address' : ucfirst($split[0]); + } + else { + $entity = 'Contact'; + } $sorted[ts($entity)][] = array('id' => $k, 'text' => $v); } } -- 2.25.1