X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=api%2Fv3%2FCustomField.php;h=09907334c399cd7b5b7ed37a68dd65bf2d856a1d;hb=8dc9d4eeae8e6667644b0dae56e0b685af95cebc;hp=020ebe2bbfdae5b7437962b19e90b49645c12bf8;hpb=060ea8f8e944292abc945b136c66cb7ccabd4fc1;p=civicrm-core.git diff --git a/api/v3/CustomField.php b/api/v3/CustomField.php index 020ebe2bbf..09907334c3 100644 --- a/api/v3/CustomField.php +++ b/api/v3/CustomField.php @@ -30,6 +30,12 @@ */ function civicrm_api3_custom_field_create($params) { + // Legacy handling for old way of naming serialized fields + if (!empty($params['html_type']) && ($params['html_type'] == 'CheckBox' || strpos($params['html_type'], 'Multi-') === 0)) { + $params['serialize'] = 1; + $params['html_type'] = str_replace('Multi-', '', $params['html_type']); + } + // Array created for passing options in params. if (isset($params['option_values']) && is_array($params['option_values'])) { $weight = 0; @@ -116,7 +122,26 @@ function civicrm_api3_custom_field_delete($params) { * @return array */ function civicrm_api3_custom_field_get($params) { - return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params); + if (($params['legacy_html_type'] ?? TRUE) && !empty($params['return'])) { + if (is_array($params['return'])) { + $params['return'][] = 'serialize'; + } + elseif (is_string($params['return'])) { + $params['return'] .= ',serialize'; + } + } + + $results = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params); + + if (($params['legacy_html_type'] ?? TRUE) && !empty($results['values']) && is_array($results['values'])) { + foreach ($results['values'] as $id => $result) { + if (!empty($result['serialize']) && !empty($result['html_type'])) { + $results['values'][$id]['html_type'] = str_replace('Select', 'Multi-Select', $result['html_type']); + } + } + } + + return $results; } /**