From 7a8e775ae6108449b729e9aad97f8c9d5b5ca44b Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Tue, 25 Nov 2014 12:59:41 -0500 Subject: [PATCH] CRM-15646 - api.setvalue: Add support for custom fields --- api/v3/Generic/Setvalue.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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); -- 2.25.1