Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/core#1953 Ensure that Contribution pages do not fail validation o… #18144

Merged
merged 1 commit into from
Aug 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seamuslee001 I don't think this should have a comma here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep true pushing a commit now

],
'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