Search code examples
formsdrupaldrupal-7credit-cardcommerce

How to change drupal commerce credit card default value


I have a drupal commerce install, the credit card on the payment pane has this has default values for the expiration month and expiration date. I have tried to change the default values to 'mm' and 'yy' but it won't work.

$form['commerce_payment']['payment_details']['credit_card']['exp_month']['#default_value']= 'mm';

$form['commerce_payment']['payment_details']['credit_card']['exp_year']['#default_value']= 'yy';

When I run

dpm($form['commerce_payment']['payment_details']['credit_card']['exp_year']['#default_value'])

it displays 'yy' but the form won't pick up the change. I can change everything else but those 2 default values.


Solution

  • You should pass an explicit numeric values to this parameter, not the date format strings.

    Look at the line #119 for the proper implementation here (click "View source" under the functions list table.