Skip to content
Snippets Groups Projects
Commit f2b53f26 authored by colemanw's avatar colemanw
Browse files

Support custom fields CRM-12464

----------------------------------------
* CRM-12464: Add PseudoConstants to Schema Metadata
  http://issues.civicrm.org/jira/browse/CRM-12464
parent ee2b1c1c
Branches
Tags
No related merge requests found
......@@ -219,6 +219,21 @@ class CRM_Core_PseudoConstant {
* @static
*/
public static function get($daoName, $fieldName, $params = array()) {
$flip = !empty($params['flip']);
// Custom fields are not in the schema
if (strpos($fieldName, 'custom') === 0) {
$dao = new CRM_Core_DAO_CustomField;
$dao->id = (int) substr($fieldName, 7);
$dao->find(TRUE);
$customField = (array) $dao;
$dao->free();
$output = array();
CRM_Core_BAO_CustomField::buildOption($customField, $output);
return $flip ? array_flip($output) : $output;
}
// Core field: load schema
$dao = new $daoName;
$fields = $dao->fields();
$fieldKeys = $dao->fieldKeys();
......@@ -228,7 +243,6 @@ class CRM_Core_PseudoConstant {
return FALSE;
}
$fieldSpec = $fields[$fieldKey];
$flip = !empty($params['flip']);
// If the field is an enum, explode the enum definition and return the array.
if (isset($fieldSpec['enumValues'])) {
......
......@@ -55,13 +55,7 @@ function civicrm_api3_generic_getfields($apiRequest) {
switch ($action) {
case 'getfields':
$values = _civicrm_api_get_fields($entity, false, $apiRequest['params']);
$results[$entity][$action] = civicrm_api3_create_success($values,
$apiRequest['params'], $entity, 'getfields'
);
return $results[$entity][$action];
case 'getfields':
return civicrm_api3_create_success(_civicrm_api_get_fields($apiRequest['entity']));
return civicrm_api3_create_success($values, $apiRequest['params'], $entity, 'getfields');
case 'create':
case 'update':
case 'replace':
......@@ -84,7 +78,6 @@ function civicrm_api3_generic_getfields($apiRequest) {
// inconsistency
$metadata['id']['api.aliases'] = array($lcase_entity . '_id');
}
break;
case 'delete':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment