You are here

function commerce_cardonfile_update_form in Commerce Card on File 7

Builds the form for updating cardonfile data.

Parameters

$card_data: The data array representing a card on file.

1 string reference to 'commerce_cardonfile_update_form'
commerce_cardonfile_update in includes/commerce_cardonfile.pages.inc
Displays the form for updating cardonfile data.

File

includes/commerce_cardonfile.pages.inc, line 61
User page callbacks and forms for Commerce Card on File.

Code

function commerce_cardonfile_update_form($form, &$form_state, $card_data) {

  // Load the credit card helper functions from the Payment module.
  module_load_include('inc', 'commerce_payment', 'includes/commerce_payment.credit_card');
  $form['card_data'] = array(
    '#type' => 'value',
    '#value' => $card_data,
  );
  $defaults = array(
    'owner' => $card_data['card_name'],
    'number' => t('(Last 4): @number', array(
      '@number' => $card_data['card_number'],
    )),
    'exp_month' => $card_data['card_exp_month'],
    'exp_year' => $card_data['card_exp_year'],
  );
  $form += commerce_payment_credit_card_form(array(
    'owner' => TRUE,
  ), $defaults);
  $form['credit_card']['number']['#description'] = t('Leaving this field alone will leave the current card number unchanged.');
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Update card data'),
    '#suffix' => l(t('Cancel'), 'user/' . $card_data['uid'] . '/stored-payment-methods'),
  );
  return $form;
}