Skip to content

Commit

Permalink
dev/core#1953 Ensure that Contribution pages do not fail validation o…
Browse files Browse the repository at this point in the history
…n credit cards when a zero dollar price is offered
  • Loading branch information
seamuslee001 committed Aug 14, 2020
1 parent 520d760 commit 6148bae
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
16 changes: 14 additions & 2 deletions CRM/Core/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ public function getPaymentFormFieldsMetadata() {
'size' => 20,
'maxlength' => 20,
'autocomplete' => 'off',
'class' => 'creditcard',
'class' => 'creditcard, required',
],
'is_required' => TRUE,
// 'description' => '16 digit card number', // If you enable a description field it will be shown below the field on the form
Expand All @@ -844,6 +844,7 @@ public function getPaymentFormFieldsMetadata() {
'size' => 5,
'maxlength' => 10,
'autocomplete' => 'off',
'class' => 'required',
],
'is_required' => $isCVVRequired,
'rules' => [
Expand All @@ -867,7 +868,7 @@ public function getPaymentFormFieldsMetadata() {
'rule_parameters' => TRUE,
],
],
'extra' => ['class' => 'crm-form-select'],
'extra' => ['class' => 'crm-form-select required'],
],
'credit_card_type' => [
'htmlType' => 'select',
Expand All @@ -884,6 +885,7 @@ public function getPaymentFormFieldsMetadata() {
'size' => 20,
'maxlength' => 34,
'autocomplete' => 'on',
'class' => 'required',
],
'is_required' => TRUE,
],
Expand All @@ -896,6 +898,7 @@ public function getPaymentFormFieldsMetadata() {
'size' => 20,
'maxlength' => 34,
'autocomplete' => 'off',
'class' => 'required',
],
'rules' => [
[
Expand All @@ -915,6 +918,7 @@ public function getPaymentFormFieldsMetadata() {
'size' => 20,
'maxlength' => 11,
'autocomplete' => 'off',
'class' => 'required',
],
'is_required' => TRUE,
'rules' => [
Expand All @@ -933,6 +937,7 @@ public function getPaymentFormFieldsMetadata() {
'size' => 20,
'maxlength' => 64,
'autocomplete' => 'off',
'class' => 'required',
],
'is_required' => TRUE,

Expand Down Expand Up @@ -1034,6 +1039,7 @@ public function getBillingAddressFieldsMetadata($billingLocationID = NULL) {
'size' => 30,
'maxlength' => 60,
'autocomplete' => 'off',
'class' => 'required',
],
'is_required' => TRUE,
];
Expand All @@ -1060,6 +1066,7 @@ public function getBillingAddressFieldsMetadata($billingLocationID = NULL) {
'size' => 30,
'maxlength' => 60,
'autocomplete' => 'off',
'class' => 'required',
],
'is_required' => TRUE,
];
Expand All @@ -1073,6 +1080,7 @@ public function getBillingAddressFieldsMetadata($billingLocationID = NULL) {
'size' => 30,
'maxlength' => 60,
'autocomplete' => 'off',
'class' => 'required',
],
'is_required' => TRUE,
];
Expand All @@ -1086,6 +1094,7 @@ public function getBillingAddressFieldsMetadata($billingLocationID = NULL) {
'size' => 30,
'maxlength' => 60,
'autocomplete' => 'off',
'class' => 'required',
],
'is_required' => TRUE,
];
Expand All @@ -1096,6 +1105,7 @@ public function getBillingAddressFieldsMetadata($billingLocationID = NULL) {
'name' => "billing_state_province_id-{$billingLocationID}",
'cc_field' => TRUE,
'is_required' => TRUE,
'extra' => ['class' => 'required'],
];

$metadata["billing_postal_code-{$billingLocationID}"] = [
Expand All @@ -1107,6 +1117,7 @@ public function getBillingAddressFieldsMetadata($billingLocationID = NULL) {
'size' => 30,
'maxlength' => 60,
'autocomplete' => 'off',
'class' => 'required',
],
'is_required' => TRUE,
];
Expand All @@ -1120,6 +1131,7 @@ public function getBillingAddressFieldsMetadata($billingLocationID = NULL) {
'' => ts('- select -'),
] + CRM_Core_PseudoConstant::country(),
'is_required' => TRUE,
'extra' => ['class' => 'required'],
];
return $metadata;
}
Expand Down
2 changes: 1 addition & 1 deletion CRM/Core/Payment/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ protected static function addCommonFields(&$form, $paymentFields) {
$field['name'],
$field['title'],
$field['attributes'],
$field['is_required'],
FALSE,
$field['extra']
);
}
Expand Down
8 changes: 6 additions & 2 deletions templates/CRM/Core/BillingBlock.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
{foreach from=$paymentFields item=paymentField}
{assign var='name' value=$form.$paymentField.name}
<div class="crm-section {$form.$paymentField.name}-section">
<div class="label">{$form.$paymentField.label}</div>
<div class="label">{$form.$paymentField.label}
{if $requiredPaymentFields.$name}<span class="crm-marker" title="{ts}This field is required.{/ts}">*</span>{/if}
</div>
<div class="content">
{$form.$paymentField.html}
{if $paymentFieldsMetadata.$name.description}
Expand Down Expand Up @@ -49,7 +51,9 @@
{foreach from=$billingDetailsFields item=billingField}
{assign var='name' value=$form.$billingField.name}
<div class="crm-section {$form.$billingField.name}-section">
<div class="label">{$form.$billingField.label}</div>
<div class="label">{$form.$billingField.label}
{if $requiredPaymentFields.$name}<span class="crm-marker" title="{ts}This field is required.{/ts}">*</span>{/if}
</div>
{if $form.$billingField.type == 'text'}
<div class="content">{$form.$billingField.html}</div>
{else}
Expand Down

0 comments on commit 6148bae

Please sign in to comment.