From e9fc038fde80e8d4e5b9cccf6c84c7167dc36f68 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Sun, 20 Jun 2021 10:43:58 +1200 Subject: [PATCH] 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 --- CRM/Event/BAO/Event.php | 9 +++++++++ 1 file changed, 9 insertions(+) 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); } -- 2.25.1