From 04b66908689a94d1b37feef0a89bcabd269cc80c Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 21 Nov 2023 15:37:01 +1300 Subject: [PATCH] Fix event merging profiles together https://lab.civicrm.org/dev/core/-/issues/4766 --- CRM/Event/Form/Registration.php | 15 ++++++++++++++- .../CRM/Event/Form/Registration/Register.tpl | 4 +++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/CRM/Event/Form/Registration.php b/CRM/Event/Form/Registration.php index 1595d77e05..f73508bbb4 100644 --- a/CRM/Event/Form/Registration.php +++ b/CRM/Event/Form/Registration.php @@ -503,8 +503,11 @@ class CRM_Event_Form_Registration extends CRM_Core_Form { * @param string $name */ public function buildCustom($id, $name) { + if ($name === 'customPost') { + $this->assign('postPageProfiles', []); + } + $this->assign($name, []); if (!$id) { - $this->assign($name, []); return; } @@ -563,6 +566,16 @@ class CRM_Event_Form_Registration extends CRM_Core_Form { ) { CRM_Core_BAO_Address::checkContactSharedAddressFields($fields, $contactID); } + if ($name === 'customPost') { + $postPageProfiles = []; + foreach ($fields as $fieldName => $field) { + $postPageProfiles[$field['groupName']][$fieldName] = $field; + } + $this->assign('postPageProfiles', $postPageProfiles); + } + // We still assign the customPost in the way we used to because we haven't ruled out being + // used after the register form - but in the register form it is overwritten by a for-each + // with the smarty code. $this->assign($name, $fields); if (is_array($fields)) { $button = substr($this->controller->getButtonName(), -4); diff --git a/templates/CRM/Event/Form/Registration/Register.tpl b/templates/CRM/Event/Form/Registration/Register.tpl index 496581b3eb..747a74e154 100644 --- a/templates/CRM/Event/Form/Registration/Register.tpl +++ b/templates/CRM/Event/Form/Registration/Register.tpl @@ -135,7 +135,9 @@ {/if}
- {include file="CRM/UF/Form/Block.tpl" fields=$customPost prefix=false hideFieldset=false} + {foreach from=$postPageProfiles item=customPost} + {include file="CRM/UF/Form/Block.tpl" fields=$customPost prefix=false hideFieldset=false} + {/foreach}
-- 2.25.1