Fix missing default values for required fields in event registration setup
authorlarssandergreen <lars@wildsight.ca>
Tue, 24 Jan 2023 19:04:07 +0000 (12:04 -0700)
committerlarssandergreen <lars@wildsight.ca>
Tue, 24 Jan 2023 19:04:07 +0000 (12:04 -0700)
CRM/Event/Form/ManageEvent/Registration.php
templates/CRM/Event/Form/ManageEvent/Registration.tpl

index c2b186cddd4bea47cfb0b7469916523c61b176e0..5b35e8ae87a0d42d086f5d68e98cfcb5feb832a2 100644 (file)
@@ -116,8 +116,7 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent
           $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 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent
             $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 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent
     }
 
     // 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'] = $defaults['registration_link_text'] ?? ts('Register Now');
+    $defaults['confirm_title'] = $defaults['confirm_title'] ?? ts('Confirm Your Registration Information');
+    $defaults['thankyou_title'] = $defaults['thankyou_title'] ?? ts('Thank You for Registering');
+    $defaults['approval_req_text'] = $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 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent
   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');
       }
index c3db65bb90d1d8a47ff62dd04af838b59e86aee0..946aaa4ebf646996b8ccdb00b8277b852d1c6242 100644 (file)
@@ -50,7 +50,7 @@
 
   <tr class="crm-event-manage-registration-form-block-registration_link_text">
     <td scope="row" class="label"
-        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}</td>
+        width="20%">{$form.registration_link_text.label} <span class="crm-marker">*</span>{if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_event' field='registration_link_text' id=$eventID}{/if}</td>
     <td>{$form.registration_link_text.html} {help id="id-link_text"}</td>
   </tr>
   {if !$isTemplate}