X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=api%2Fv3%2Futils.php;h=14f6daa352ffbea6d20a59df98bc6410040b507a;hb=d75241a408e82529568c540996dc3e35b7207288;hp=f8aeff580eb5354037306a74fcde8cb13ca681df;hpb=4d32d50b462d76a14faf7a6f732816ee9fe40ee6;p=civicrm-core.git diff --git a/api/v3/utils.php b/api/v3/utils.php index f8aeff580e..14f6daa352 100644 --- a/api/v3/utils.php +++ b/api/v3/utils.php @@ -1,7 +1,7 @@ $value) { // Regular fields have a 'name' property $value['name'] = 'custom_' . $key; + $value['type'] = _getStandardTypeFromCustomDataType($value['data_type']); $customfields['custom_' . $key] = $value; if (in_array('custom_' . $key, $getoptions)) { $customfields['custom_' . $key]['options'] = CRM_Core_BAO_CustomOption::valuesByID($key); @@ -1343,17 +1344,35 @@ function _civicrm_api_get_custom_fields($entity, &$params) { } return $customfields; } - +/** + * Translate the custom field data_type attribute into a std 'type' + */ +function _getStandardTypeFromCustomDataType($dataType) { + $mapping = array( + 'String' => CRM_Utils_Type::T_STRING, + 'Int' => CRM_Utils_Type::T_INT, + 'Money' => CRM_Utils_Type::T_MONEY, + 'Memo' => CRM_Utils_Type::T_LONGTEXT, + 'Float' => CRM_Utils_Type::T_FLOAT, + 'Date' => CRM_Utils_Type::T_DATE, + 'Boolean' => CRM_Utils_Type::T_BOOLEAN, + 'StateProvince' => CRM_Utils_Type::T_INT, + 'File' => CRM_Utils_Type::T_STRING, + 'Link' => CRM_Utils_Type::T_STRING, + 'ContactReference' => CRM_Utils_Type::T_INT, + 'Country' => CRM_Utils_Type::T_INT, + ); + return $mapping[$dataType]; +} /** * Return array of defaults for the given API (function is a wrapper on getfields) */ function _civicrm_api3_getdefaults($apiRequest) { $defaults = array(); - $result = civicrm_api($apiRequest['entity'], + $result = civicrm_api3($apiRequest['entity'], 'getfields', array( - 'version' => 3, 'action' => $apiRequest['action'], ) ); @@ -1401,10 +1420,9 @@ function _civicrm_api3_swap_out_aliases(&$apiRequest) { } return; } - $result = civicrm_api($apiRequest['entity'], + $result = civicrm_api3($apiRequest['entity'], 'getfields', array( - 'version' => 3, 'action' => $apiRequest['action'], ) );