From bccb82618124f7a6426f88c1932bf0a852f9376a Mon Sep 17 00:00:00 2001 From: larssandergreen Date: Mon, 23 Jan 2023 23:56:16 -0700 Subject: [PATCH] @larssandergreen Fix missing default value for event registration setup --- CRM/Event/Form/ManageEvent/Registration.php | 16 +++++++++------- .../CRM/Event/Form/ManageEvent/Registration.tpl | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CRM/Event/Form/ManageEvent/Registration.php b/CRM/Event/Form/ManageEvent/Registration.php index c2b186cddd4b..8101e6b6d897 100644 --- a/CRM/Event/Form/ManageEvent/Registration.php +++ b/CRM/Event/Form/ManageEvent/Registration.php @@ -116,8 +116,7 @@ public function setDefaultValues() { $defaults["custom_post_id_multiple[$key]"] = $value; } } - - $this->assign('profilePostMultiple', CRM_Utils_Array::value('custom_post', $defaults)); + $this->assign('profilePostMultiple', $defaults['custom_post'] ?? NULL); // CRM-17745: Make max additional participants configurable if (empty($defaults['max_additional_participants'])) { @@ -149,7 +148,7 @@ public function setDefaultValues() { $defaults["additional_custom_post_id_multiple[$key]"] = $value; } } - $this->assign('profilePostMultipleAdd', CRM_Utils_Array::value('additional_custom_post', $defaults, [])); + $this->assign('profilePostMultipleAdd', $defaults['additional_custom_post'] ?? []); } else { // Avoid PHP notices in the template @@ -161,10 +160,10 @@ public function setDefaultValues() { } // provide defaults for required fields if empty (and as a 'hint' for approval message field) - $defaults['registration_link_text'] = CRM_Utils_Array::value('registration_link_text', $defaults, ts('Register Now')); - $defaults['confirm_title'] = CRM_Utils_Array::value('confirm_title', $defaults, ts('Confirm Your Registration Information')); - $defaults['thankyou_title'] = CRM_Utils_Array::value('thankyou_title', $defaults, ts('Thank You for Registering')); - $defaults['approval_req_text'] = CRM_Utils_Array::value('approval_req_text', $defaults, ts('Participation in this event requires approval. Submit your registration request here. Once approved, you will receive an email with a link to a web page where you can complete the registration process.')); + $defaults['registration_link_text'] ??= ts('Register Now'); + $defaults['confirm_title'] ??= ts('Confirm Your Registration Information'); + $defaults['thankyou_title'] ??= ts('Thank You for Registering'); + $defaults['approval_req_text'] ??= ts('Participation in this event requires approval. Submit your registration request here. Once approved, you will receive an email with a link to a web page where you can complete the registration process.'); return $defaults; } @@ -442,6 +441,9 @@ public function addRules() { public static function formRule($values, $files, $form) { if (!empty($values['is_online_registration'])) { + if (!$values['registration_link_text']) { + $errorMsg['registration_link_text'] = ts('Please enter Registration Link Text'); + } if (!$values['confirm_title']) { $errorMsg['confirm_title'] = ts('Please enter a Title for the registration Confirmation Page'); } diff --git a/templates/CRM/Event/Form/ManageEvent/Registration.tpl b/templates/CRM/Event/Form/ManageEvent/Registration.tpl index c3db65bb90d1..946aaa4ebf64 100644 --- a/templates/CRM/Event/Form/ManageEvent/Registration.tpl +++ b/templates/CRM/Event/Form/ManageEvent/Registration.tpl @@ -50,7 +50,7 @@ {$form.registration_link_text.label} {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_event' field='registration_link_text' id=$eventID}{/if} + width="20%">{$form.registration_link_text.label} *{if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_event' field='registration_link_text' id=$eventID}{/if} {$form.registration_link_text.html} {help id="id-link_text"} {if !$isTemplate}