From 4533376a6b107ab3ad24359f0670ddc9b035dff8 Mon Sep 17 00:00:00 2001 From: "Matthew Wire (MJW Consulting)" Date: Thu, 23 Aug 2018 11:12:34 +0100 Subject: [PATCH] Allow descriptions for payment fields (add via paymentFieldsMetaData 'description' --- CRM/Core/Payment.php | 1 + CRM/Core/Payment/Form.php | 4 +++- templates/CRM/Core/BillingBlock.tpl | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CRM/Core/Payment.php b/CRM/Core/Payment.php index 13f506bcd1..25de4a781f 100644 --- a/CRM/Core/Payment.php +++ b/CRM/Core/Payment.php @@ -689,6 +689,7 @@ abstract class CRM_Core_Payment { 'class' => 'creditcard', ), 'is_required' => TRUE, + // 'description' => '16 digit card number', // If you enable a description field it will be shown below the field on the form ), 'cvv2' => array( 'htmlType' => 'text', diff --git a/CRM/Core/Payment/Form.php b/CRM/Core/Payment/Form.php index 60e946d7dd..1200aef0e3 100644 --- a/CRM/Core/Payment/Form.php +++ b/CRM/Core/Payment/Form.php @@ -113,7 +113,7 @@ class CRM_Core_Payment_Form { * Fields that are to be shown on the payment form. */ protected static function addCommonFields(&$form, $paymentFields) { - $requiredPaymentFields = array(); + $requiredPaymentFields = $paymentFieldsMetadata = []; foreach ($paymentFields as $name => $field) { if ($field['htmlType'] == 'chainSelect') { $form->addChainSelect($field['name'], array('required' => FALSE)); @@ -129,8 +129,10 @@ class CRM_Core_Payment_Form { // This will cause the fields to be marked as required - but it is up to the payment processor to // validate it. $requiredPaymentFields[$field['name']] = $field['is_required']; + $paymentFieldsMetadata[$field['name']] = $field; } + $form->assign('paymentFieldsMetadata', $paymentFieldsMetadata); $form->assign('requiredPaymentFields', $requiredPaymentFields); } diff --git a/templates/CRM/Core/BillingBlock.tpl b/templates/CRM/Core/BillingBlock.tpl index 73050a5e37..3e15fce070 100644 --- a/templates/CRM/Core/BillingBlock.tpl +++ b/templates/CRM/Core/BillingBlock.tpl @@ -41,7 +41,9 @@
{$form.$paymentField.html} - {if $paymentField == 'cvv2'}{* @todo move to form assignment*} + {if $paymentFieldsMetadata.$name.description} +
{$paymentFieldsMetadata.$name.description}
+ {elseif $paymentField == 'cvv2'}{* @todo move to form assignment*} {/if} {if $paymentField == 'credit_card_type'} -- 2.25.1