Skip to content

Commit

Permalink
Merge pull request #12721 from mattwire/billingblock_descriptions
Browse files Browse the repository at this point in the history
Allow descriptions for payment fields
  • Loading branch information
eileenmcnaughton authored Sep 13, 2018
2 parents c454b0e + 4533376 commit 53258b7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions CRM/Core/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,7 @@ public function getPaymentFormFieldsMetadata() {
'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',
Expand Down
4 changes: 3 additions & 1 deletion CRM/Core/Payment/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ static protected function setBillingAddressFields(&$form, $processor) {
* 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));
Expand All @@ -129,8 +129,10 @@ protected static function addCommonFields(&$form, $paymentFields) {
// 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);
}

Expand Down
4 changes: 3 additions & 1 deletion templates/CRM/Core/BillingBlock.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
</div>
<div class="content">
{$form.$paymentField.html}
{if $paymentField == 'cvv2'}{* @todo move to form assignment*}
{if $paymentFieldsMetadata.$name.description}
<div class="description">{$paymentFieldsMetadata.$name.description}</div>
{elseif $paymentField == 'cvv2'}{* @todo move to form assignment*}
<span class="cvv2-icon" title="{ts}Usually the last 3-4 digits in the signature area on the back of the card.{/ts}"> </span>
{/if}
{if $paymentField == 'credit_card_type'}
Expand Down

0 comments on commit 53258b7

Please sign in to comment.