Merge pull request #23974 from colemanw/filterFieldsAfform
[civicrm-core.git] / CRM / Event / Form / EventFees.php
index 192e54008e2e0dc187c3b3c4ab110f3a386c6867..2b15c288cef972ecb51c2c820849c9c0c13e9593 100644 (file)
@@ -159,6 +159,7 @@ class CRM_Event_Form_EventFees {
       if (in_array(get_class($form),
         [
           'CRM_Event_Form_Participant',
+          'CRM_Event_Form_Task_Register',
           'CRM_Event_Form_Registration_Register',
           'CRM_Event_Form_Registration_AdditionalParticipant',
         ]
@@ -173,7 +174,7 @@ class CRM_Event_Form_EventFees {
         foreach ($form->_priceSet['fields'] as $key => $val) {
           foreach ($val['options'] as $keys => $values) {
             if ($values['is_default']) {
-              if (get_class($form) != 'CRM_Event_Form_Participant' && !empty($values['is_full'])) {
+              if (!in_array(get_class($form), ['CRM_Event_Form_Participant', 'CRM_Event_Form_Task_Register']) && !empty($values['is_full'])) {
                 continue;
               }
 
@@ -254,8 +255,8 @@ class CRM_Event_Form_EventFees {
 
       $priceFields = $htmlTypes = $optionValues = [];
       foreach ($lineItems[$participantID] as $lineId => $items) {
-        $priceFieldId = CRM_Utils_Array::value('price_field_id', $items);
-        $priceOptionId = CRM_Utils_Array::value('price_field_value_id', $items);
+        $priceFieldId = $items['price_field_id'] ?? NULL;
+        $priceOptionId = $items['price_field_value_id'] ?? NULL;
         if ($priceFieldId && $priceOptionId) {
           $priceFields[$priceFieldId][] = $priceOptionId;
         }
@@ -277,7 +278,7 @@ SELECT  id, html_type
 
       foreach ($lineItems[$participantID] as $lineId => $items) {
         $fieldId = $items['price_field_id'];
-        $htmlType = CRM_Utils_Array::value($fieldId, $htmlTypes);
+        $htmlType = $htmlTypes[$fieldId] ?? NULL;
         if (!$htmlType) {
           continue;
         }
@@ -286,7 +287,7 @@ SELECT  id, html_type
           $defaults["price_{$fieldId}"] = $items['qty'];
         }
         else {
-          $fieldOptValues = CRM_Utils_Array::value($fieldId, $priceFields);
+          $fieldOptValues = $priceFields[$fieldId] ?? NULL;
           if (!is_array($fieldOptValues)) {
             continue;
           }