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
$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);
}