From 000652dc7a863aee358a2de5c08c33e0c9f8b3a3 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Mon, 15 Jul 2013 17:51:21 -0700 Subject: [PATCH] Support "unique names" as well as sql name CRM-12464 ---------------------------------------- * CRM-12464: Add PseudoConstants to Schema Metadata http://issues.civicrm.org/jira/browse/CRM-12464 --- CRM/Core/PseudoConstant.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/CRM/Core/PseudoConstant.php b/CRM/Core/PseudoConstant.php index 82faf63e33..2cabc11fb2 100644 --- a/CRM/Core/PseudoConstant.php +++ b/CRM/Core/PseudoConstant.php @@ -260,8 +260,14 @@ class CRM_Core_PseudoConstant { $dao = new $daoName; $fields = $dao->fields(); $fieldKeys = $dao->fieldKeys(); - $fieldKey = $fieldKeys[$fieldName]; $dao->free(); + + // Support "unique names" as well as sql names + $fieldKey = $fieldName; + if (empty($fields[$fieldKey])) { + $fieldKey = $fieldKeys[$fieldName]; + } + // If neither worked then this field doesn't exist. Return false. if (empty($fields[$fieldKey])) { return FALSE; } @@ -320,9 +326,7 @@ class CRM_Core_PseudoConstant { return FALSE; } // Get list of fields for the option table - $dao = new $daoName; - $availableFields = array_keys($dao->fieldKeys()); - $dao->free(); + $availableFields = array_keys($fieldKeys); $select = "SELECT %1 AS id, %2 AS label"; $from = "FROM %3"; -- 2.25.1