CRM-13475 Fix credit-card error messages
authorColeman Watts <coleman@civicrm.org>
Thu, 3 Oct 2013 13:00:07 +0000 (14:00 +0100)
committerColeman Watts <coleman@civicrm.org>
Thu, 3 Oct 2013 13:00:07 +0000 (14:00 +0100)
----------------------------------------
* CRM-13475: Entering an invalid credit card number gives the wrong field validation error
  http://issues.civicrm.org/jira/browse/CRM-13475

CRM/Core/Payment/Form.php

index 48faa6b0bd9ce116826da90e980410cb9bbe6b26..f193753892eec2a6cd9adccebf3f10871b953902 100644 (file)
@@ -182,7 +182,7 @@ class CRM_Core_Payment_Form {
       'title' => ts('Card Type'),
       'cc_field' => TRUE,
       'attributes' => $creditCardType,
-      'is_required' => TRUE,
+      'is_required' => FALSE,
     );
   }
 
@@ -237,7 +237,7 @@ class CRM_Core_Payment_Form {
   /**
    * Function to add all the credit card fields
    *
-   * @return None
+   * @return void
    * @access public
    */
   static function buildCreditCard(&$form, $useRequired = FALSE) {
@@ -363,6 +363,9 @@ class CRM_Core_Payment_Form {
         $errors['cvv2'] = ts('Please enter a valid Credit Card Verification Number');
       }
     }
+    elseif (!empty($values['credit_card_number'])) {
+      $errors['credit_card_number'] = ts('Please enter a valid Credit Card Number and Type');
+    }
   }
 
   /**