From: Coleman Watts Date: Tue, 25 Nov 2014 17:59:41 +0000 (-0500) Subject: CRM-15646 - api.setvalue: Add support for custom fields X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=7a8e775ae6108449b729e9aad97f8c9d5b5ca44b;p=civicrm-core.git CRM-15646 - api.setvalue: Add support for custom fields --- diff --git a/api/v3/Generic/Setvalue.php b/api/v3/Generic/Setvalue.php index cae77e1193..53c136d850 100644 --- a/api/v3/Generic/Setvalue.php +++ b/api/v3/Generic/Setvalue.php @@ -72,7 +72,15 @@ function civicrm_api3_generic_setValue($apiRequest) { $params = array('id' => $id, $field => $value); CRM_Utils_Hook::pre('edit', $entity, $id, $params); - if (CRM_Core_DAO::setFieldValue($dao_name, $id, $field, $params[$field])) { + // Custom fields + if (strpos($field, 'custom_') === 0) { + CRM_Utils_Array::crmReplaceKey($params, 'id', 'entityID'); + CRM_Core_BAO_CustomValueTable::setValues($params); + CRM_Utils_Hook::post('edit', $entity, $id, CRM_Core_DAO::$_nullObject); + return civicrm_api3_create_success($params); + } + // Core fields + elseif (CRM_Core_DAO::setFieldValue($dao_name, $id, $field, $params[$field])) { $entityDAO = new $dao_name(); $entityDAO->copyValues($params); CRM_Utils_Hook::post('edit', $entity, $entityDAO->id, $entityDAO);