0

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.

amdixon
  • 3,814
  • 8
  • 25
  • 34
JNL
  • 13
  • 4

1 Answers1

0

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.

Dmytro Sukhovoy
  • 952
  • 5
  • 17
  • Thanks for pointing me there but I want to pass 'mm' and 'yy' as respective default values of the exp_month and exp_year. – JNL Oct 24 '15 at 20:28
  • as it is a select element you have to have 'MM' in an options list first. `$form['commerce_payment']['payment_details']['credit_card']['exp_month'][#options]['mm'] = 'MM';` – Dmytro Sukhovoy Oct 24 '15 at 20:43
  • The above solution will make your default "MM" value available for users to select. It's not the best possible way. Maybe you need smth like [Compact forms module](https://www.drupal.org/project/compact_forms) or just a bit of js magic? – Dmytro Sukhovoy Oct 24 '15 at 21:04