From: Coleman Watts Date: Tue, 16 Jul 2013 00:51:21 +0000 (-0700) Subject: Support "unique names" as well as sql name CRM-12464 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=000652dc7a863aee358a2de5c08c33e0c9f8b3a3;p=civicrm-core.git 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 --- 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";