Proceeding to confirmation page should be a "next" button not a check
[civicrm-core.git] / CRM / Event / Form / Registration / Register.php
index be483125d794c71b4cf4cbe4836d26cc92671c69..a2bc57ef5f7218ca9e58135637a9cca5c4942af6 100644 (file)
@@ -152,7 +152,7 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
     $this->_allowWaitlist = FALSE;
     if ($eventFull && !$this->_allowConfirmation && !empty($this->_values['event']['has_waitlist'])) {
       $this->_allowWaitlist = TRUE;
-      $this->_waitlistMsg = CRM_Utils_Array::value('waitlist_text', $this->_values['event']);
+      $this->_waitlistMsg = $this->_values['event']['waitlist_text'] ?? NULL;
       if (!$this->_waitlistMsg) {
         $this->_waitlistMsg = ts('This event is currently full. However you can register now and get added to a waiting list. You will be notified if spaces become available.');
       }
@@ -398,16 +398,7 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
     }
 
     if ($this->_values['event']['is_monetary']) {
-      if (count($pps) > 1) {
-        $this->addRadio('payment_processor_id', ts('Payment Method'), $pps,
-          NULL, " "
-        );
-      }
-      elseif (!empty($pps)) {
-        $ppKeys = array_keys($pps);
-        $currentPP = array_pop($ppKeys);
-        $this->addElement('hidden', 'payment_processor_id', $currentPP);
-      }
+      $this->addPaymentProcessorFieldsToForm();
     }
 
     $this->addElement('hidden', 'bypass_payment', NULL, ['id' => 'bypass_payment']);
@@ -476,25 +467,24 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
 
       // CRM-11182 - Optional confirmation screen
       // Change button label depending on whether the next action is confirm or register
+      $buttonParams = [
+        'type' => 'upload',
+        'spacing' => '         ',
+        'isDefault' => TRUE,
+      ];
       if (
         !$this->_values['event']['is_multiple_registrations']
         && !$this->_values['event']['is_monetary']
         && !$this->_values['event']['is_confirm_enabled']
       ) {
-        $buttonLabel = ts('Register');
+        $buttonParams['name'] = ts('Register');
       }
       else {
-        $buttonLabel = ts('Continue');
+        $buttonParams['name'] = ts('Review your registration');
+        $buttonParams['icon'] = 'fa-chevron-right';
       }
 
-      $this->addButtons([
-        [
-          'type' => 'upload',
-          'name' => $buttonLabel,
-          'spacing' => '         ',
-          'isDefault' => TRUE,
-        ],
-      ]);
+      $this->addButtons([$buttonParams]);
     }
 
     $this->addFormRule(['CRM_Event_Form_Registration_Register', 'formRule'], $this);
@@ -528,18 +518,18 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
     //if payment done, no need to build the fee block.
     if (!empty($form->_paymentId)) {
       //fix to display line item in update mode.
-      $form->assign('priceSet', isset($form->_priceSet) ? $form->_priceSet : NULL);
+      $form->assign('priceSet', $form->_priceSet ?? NULL);
       return;
     }
 
-    $feeFields = CRM_Utils_Array::value('fee', $form->_values);
+    $feeFields = $form->_values['fee'] ?? NULL;
 
     if (is_array($feeFields)) {
       $form->_feeBlock = &$form->_values['fee'];
     }
 
     //check for discount.
-    $discountedFee = CRM_Utils_Array::value('discount', $form->_values);
+    $discountedFee = $form->_values['discount'] ?? NULL;
     if (is_array($discountedFee) && !empty($discountedFee)) {
       if (!$discountId) {
         $form->_discountId = $discountId = CRM_Core_BAO_Discount::findSet($form->_eventId, 'civicrm_event');
@@ -595,13 +585,13 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
           $fieldId = $field['id'];
           $elementName = 'price_' . $fieldId;
 
-          $isRequire = CRM_Utils_Array::value('is_required', $field);
+          $isRequire = $field['is_required'] ?? NULL;
           if ($button == 'skip') {
             $isRequire = FALSE;
           }
 
           //user might modified w/ hook.
-          $options = CRM_Utils_Array::value('options', $field);
+          $options = $field['options'] ?? NULL;
           $formClasses = ['CRM_Event_Form_Participant', 'CRM_Event_Form_ParticipantFeeSelection'];
 
           if (!is_array($options)) {
@@ -663,7 +653,7 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
       }
       $form->assign('eventFeeBlockValues', json_encode($eventFeeBlockValues));
 
-      $form->_defaults['amount'] = CRM_Utils_Array::value('default_fee_id', $form->_values['event']);
+      $form->_defaults['amount'] = $form->_values['event']['default_fee_id'] ?? NULL;
       $element = &$form->addGroup($elements, 'amount', ts('Event Fee(s)'), '<br />');
       if (isset($form->_online) && $form->_online) {
         $element->freeze();
@@ -695,7 +685,7 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
 
     $skipParticipants = $formattedPriceSetDefaults = [];
     if (!empty($form->_allowConfirmation) && (isset($form->_pId) || isset($form->_additionalParticipantId))) {
-      $participantId = isset($form->_pId) ? $form->_pId : $form->_additionalParticipantId;
+      $participantId = $form->_pId ?? $form->_additionalParticipantId;
       $pricesetDefaults = CRM_Event_Form_EventFees::setDefaultPriceSet($participantId,
         $form->_eventId
       );
@@ -976,7 +966,7 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
       $params['campaign_id'] = $params['participant_campaign_id'];
     }
     else {
-      $params['campaign_id'] = CRM_Utils_Array::value('campaign_id', $this->_values['event']);
+      $params['campaign_id'] = $this->_values['event']['campaign_id'] ?? NULL;
     }
 
     //hack to allow group to register w/ waiting