CRM-13710 fix - Required prices sets still required even when not active
authormonishdeb <monish.deb@webaccess.co.in>
Wed, 11 Dec 2013 06:00:56 +0000 (11:30 +0530)
committermonishdeb <monish.deb@webaccess.co.in>
Wed, 11 Dec 2013 06:00:56 +0000 (11:30 +0530)
http://issues.civicrm.org/jira/browse/CRM-13710

CRM/Price/BAO/PriceSet.php

index 1c4ed9675a3f11a171c8e0761d3af1ab8dcef2b6..df0ee14558425a317b432d0e31c8cf6148acb987 100644 (file)
@@ -802,6 +802,7 @@ WHERE  id = %1";
 
     $priceSet           = self::getSetDetail($priceSetId, TRUE, $validFieldsOnly);
     $form->_priceSet    = CRM_Utils_Array::value($priceSetId, $priceSet);
+    $validPriceFieldIds = array_keys($form->_priceSet['fields']);
     $form->_quickConfig = $quickConfig = 0;
     if (CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceSetId, 'is_quick_config')) {
       $quickConfig = 1;
@@ -831,7 +832,7 @@ WHERE  id = %1";
     // call the hook.
     CRM_Utils_Hook::buildAmount($component, $form, $feeBlock);
 
-    foreach ($feeBlock as $field) {
+    foreach ($feeBlock as $id => $field) {
       if (CRM_Utils_Array::value('visibility', $field) == 'public' ||
         !$validFieldsOnly
       ) {
@@ -842,7 +843,7 @@ WHERE  id = %1";
             $form->assign('ispricelifetime', TRUE);
           }
         }
-        if (!is_array($options)) {
+        if (!is_array($options) || !in_array($id, $validPriceFieldIds)) {
           continue;
         }
         CRM_Price_BAO_PriceField::addQuickFormElement($form,