From: Eileen McNaughton Date: Sat, 19 Jun 2021 22:43:58 +0000 (+1200) Subject: dev/event#58 Ensure custom data is not saved to template's row X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=e9fc038fde80e8d4e5b9cccf6c84c7167dc36f68;p=civicrm-core.git dev/event#58 Ensure custom data is not saved to template's row This ensures than when we are copying (implicity a create-new-action) we do not update an existing row in the custom data table by explicity unsetting the id in the copy function. This has been bouncey behaviour because the formatting for form purposes relies on form type formatting and yet for save purposes it's not really fit for purpose. Although a bit hacky this approach should be robust & avoids a re-write on the form --- diff --git a/CRM/Event/BAO/Event.php b/CRM/Event/BAO/Event.php index 8f347dce0a..8501319ed2 100644 --- a/CRM/Event/BAO/Event.php +++ b/CRM/Event/BAO/Event.php @@ -994,6 +994,15 @@ WHERE civicrm_event.is_active = 1 $copyEvent->save(); if ($blockCopyOfCustomValue) { + foreach ($params['custom'] as &$values) { + foreach ($values as &$value) { + // Ensure we don't copy over the template's id if it is passed in + // This is a bit hacky but it's unclear what the + // right behaviour is given the whole 'custom' + // field is form layer formatting that is reaching the BAO. + $value['id'] = NULL; + } + } CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_event', $copyEvent->id); }