From d60a6fba92f9e0f8f14381010f1caba791201390 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sun, 29 Mar 2015 18:05:46 -0400 Subject: [PATCH] CRM-16178 - Additional sugar in api.getoption --- CRM/Core/Form.php | 2 +- api/v3/Generic.php | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index bd6205f91f..a9554e944d 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -1175,7 +1175,7 @@ class CRM_Core_Form extends HTML_QuickForm_Page { $props['action'] = $this->getApiAction(); } // Get field metadata. - $fieldSpec = civicrm_api3($props['entity'], 'getfield', array('options' => array('get_options' => 1)) + $props); + $fieldSpec = civicrm_api3($props['entity'], 'getfield', $props); $fieldSpec = $fieldSpec['values']; $label = CRM_Utils_Array::value('label', $props, $fieldSpec['title']); diff --git a/api/v3/Generic.php b/api/v3/Generic.php index 703c23ca7c..da1754236b 100644 --- a/api/v3/Generic.php +++ b/api/v3/Generic.php @@ -221,12 +221,10 @@ function civicrm_api3_generic_getfield($apiRequest) { } // Turn off sequential to make the field easier to find $apiRequest['params']['sequential'] = 0; - if (!empty($params['options']['get_options'])) { + if (isset($params['get_options'])) { + $apiRequest['params']['options']['get_options_context'] = $params['get_options']; $apiRequest['params']['options']['get_options'] = $fieldName; } - if (isset($params['context'])) { - $apiRequest['params']['options']['get_options_context'] = $params['context']; - } $result = civicrm_api3_generic_getfields($apiRequest, FALSE); $result = $result['values'][$fieldName]; // Fix sequential options since we forced it off @@ -251,11 +249,12 @@ function _civicrm_api3_generic_getfield_spec(&$params, $apiRequest) { 'type' => CRM_Utils_Type::T_STRING, 'api.aliases' => array('api_action'), ), - 'context' => array( - 'title' => 'Context', - 'description' => 'Context passed to getoptions. Only relevant if options.get_options is set.', + 'get_options' => array( + 'title' => 'Get Options', + 'description' => 'Context for which to get field options, or null to skip fetching options.', 'type' => CRM_Utils_Type::T_STRING, 'options' => CRM_Core_DAO::buildOptionsContext(), + 'api.aliases' => array('context'), ), ); // Add available options to these params if requested -- 2.25.1