From: Mattias Michaux Date: Tue, 6 Jan 2015 23:07:43 +0000 (+0100) Subject: Fix to correctly determine the type of a datetime custom field. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=d2c56cb4146fe4a474ba071ba8eda5a6f54505e0;p=civicrm-core.git Fix to correctly determine the type of a datetime custom field. --- diff --git a/api/v3/utils.php b/api/v3/utils.php index 988016a1f3..6333488201 100644 --- a/api/v3/utils.php +++ b/api/v3/utils.php @@ -1815,7 +1815,7 @@ function _civicrm_api_get_custom_fields($entity, &$params) { // Regular fields have a 'name' property $value['name'] = 'custom_' . $key; $value['title'] = $value['label']; - $value['type'] = _getStandardTypeFromCustomDataType($value['data_type']); + $value['type'] = _getStandardTypeFromCustomDataType($value['data_type'], $value); $ret['custom_' . $key] = $value; } return $ret; @@ -1828,7 +1828,10 @@ function _civicrm_api_get_custom_fields($entity, &$params) { * * @return int */ -function _getStandardTypeFromCustomDataType($dataType) { +function _getStandardTypeFromCustomDataType($dataType, $value) { + if ($dataType == 'Date' && isset($value['time_format']) && $value['time_format'] > 0) { + $dataType = 'DateTime'; + } $mapping = array( 'String' => CRM_Utils_Type::T_STRING, 'Int' => CRM_Utils_Type::T_INT, @@ -1836,6 +1839,7 @@ function _getStandardTypeFromCustomDataType($dataType) { 'Memo' => CRM_Utils_Type::T_LONGTEXT, 'Float' => CRM_Utils_Type::T_FLOAT, 'Date' => CRM_Utils_Type::T_DATE, + 'DateTime' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME, 'Boolean' => CRM_Utils_Type::T_BOOLEAN, 'StateProvince' => CRM_Utils_Type::T_INT, 'File' => CRM_Utils_Type::T_STRING,