Change event registration button text based on if there are additional participants
authorlarssandergreen@gmail.com <larssandergreen@gmail.com>
Mon, 2 Aug 2021 23:03:11 +0000 (17:03 -0600)
committerlarssandergreen@gmail.com <larssandergreen@gmail.com>
Tue, 3 Aug 2021 14:15:27 +0000 (08:15 -0600)
cleanup

fix typo in description

CRM/Event/Form/Registration/Register.php
templates/CRM/Event/Form/Registration/Register.tpl

index 163badbf5e2b98d346f080e7a93a227dc9cede21..4f7daa1f42be9b2bba052fe784af56b78e8bb0b8 100644 (file)
@@ -378,8 +378,7 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
         $this->add('select', 'additional_participants',
           ts('How many people are you registering?'),
           $additionalOptions,
-          NULL,
-          ['onChange' => "allowParticipant()"]
+          NULL
         );
         $isAdditionalParticipants = TRUE;
       }
@@ -514,7 +513,7 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
         $buttonParams['name'] = ts('Register');
       }
       else {
-        $buttonParams['name'] = ts('Review your registration');
+        $buttonParams['name'] = ts('Review');
         $buttonParams['icon'] = 'fa-chevron-right';
       }
 
index a76a3c8dfe9ce87446b04359f930eb7b71da09d1..9fbd63c849bff9069516443dfb86f2dc41e9a213 100644 (file)
       <div class="crm-public-form-item crm-section additional_participants-section" id="noOfparticipants">
         <div class="label">{$form.additional_participants.label} <span class="crm-marker" title="{ts}This field is required.{/ts}">*</span></div>
         <div class="content">
-          {$form.additional_participants.html}{if $contact_id || $contact_id == NULL}{ts}(including yourself){/ts}{/if}
+          {$form.additional_participants.html}{if $contact_id || $contact_id == NULL}&nbsp;{ts}(including yourself){/ts}{/if}
           <br/>
-          <span
-            class="description">{ts}Fill in your registration information on this page. If you are registering additional people, you will be able to enter their registration information after you complete this page and click &quot;Review your registration&quot;.{/ts}</span>
+          <div class="description" id="additionalParticipantsDescription" style="display: none;">{ts}Fill in your registration information on this page. You will be able to enter the registration information for additional people after you complete this page and click &quot;Continue&quot;.{/ts}</div>
         </div>
         <div class="clear"></div>
       </div>
   {/if}
   {literal}
 
+  CRM.$(function($) {
+    $('#additional_participants').change(function() {
+      toggleAdditionalParticipants();
+      allowParticipant();
+    });
+
+    function toggleAdditionalParticipants() {
+      var submit_button = $("#crm-submit-buttons > button").html();
+      var review_translated = '{/literal}{ts escape="js"}Review{/ts}{literal}';
+      var continue_translated = '{/literal}{ts escape="js"}Continue{/ts}{literal}';
+      if ($('#additional_participants').val()) {
+        $("#additionalParticipantsDescription").show();
+        $("#crm-submit-buttons > button").html(submit_button.replace(review_translated, continue_translated));
+      } else {
+        $("#additionalParticipantsDescription").hide();
+        $("#crm-submit-buttons > button").html(submit_button.replace(continue_translated, review_translated));
+      }
+    }
+  });
+
   function allowParticipant() {
     {/literal}{if $allowGroupOnWaitlist}{literal}
     var additionalParticipants = cj('#additional_participants').val();