fix creating new event from template
authorbenjamin <ufundo@gmail.com>
Mon, 27 Mar 2023 13:52:52 +0000 (13:52 +0000)
committerbenjamin <ufundo@gmail.com>
Mon, 27 Mar 2023 19:49:22 +0000 (20:49 +0100)
CRM/Event/BAO/Event.php

index 62c1a04389113180345aad968ff4d5daeef8bded..55503aad232d2bca1253b28b5d22addf2e1a2086 100644 (file)
@@ -108,7 +108,12 @@ class CRM_Event_BAO_Event extends CRM_Event_DAO_Event implements \Civi\Core\Hook
       if (!empty($params['template_id'])) {
         $copy = self::copy($params['template_id']);
         $params['id'] = $copy->id;
+
         unset($params['template_id']);
+        // unless we are explicitly trying to create a new template
+        // we want to set the `is_template` flag on the clone to false
+        // so that the copy is a new event rather than a new template
+        $params['is_template'] = $params['is_template'] ?? 0;
 
         //fix for api from template creation bug
         civicrm_api4('ActionSchedule', 'update', [