You are here

function commerce_cop_edit_payment_form in Commerce Custom Offline Payments 7

Form to edit checkout payment.

1 string reference to 'commerce_cop_edit_payment_form'
commerce_cop_menu in ./commerce_cop.module
Implements hook_menu().

File

./commerce_cop.admin.inc, line 40
Custom offline payment methods for Drupal Commerce.

Code

function commerce_cop_edit_payment_form($form, $form_state, $payment = array()) {
  $form['title'] = array(
    '#type' => 'textfield',
    '#size' => 30,
    '#title' => t('Title'),
    '#required' => TRUE,
    '#default_value' => isset($payment['title']) ? $payment['title'] : '',
  );
  $form['id'] = array(
    '#type' => 'machine_name',
    '#title' => t('Machine name'),
    '#maxlength' => 32,
    '#required' => TRUE,
    '#default_value' => isset($payment['id']) ? $payment['id'] : '',
    '#disabled' => isset($payment['id']),
    '#machine_name' => array(
      'exists' => 'custom_offline_payment_load',
      'source' => array(
        'title',
      ),
    ),
  );
  $form['description'] = array(
    '#type' => 'textarea',
    '#title' => t('Description'),
    '#description' => t('Help text displayed to end user on checkout payment.'),
    '#default_value' => isset($payment['description']) ? $payment['description'] : '',
  );
  $information_description = t('Information you would like to be shown to users when they select this payment method, such as delivery payment details.');
  $information_description .= '<br />';
  $information_description .= t('This could be used as default information for the new payment method rules of this payment.');
  $form['information'] = array(
    '#type' => 'text_format',
    '#title' => t('Information'),
    '#description' => $information_description,
    '#default_value' => isset($payment['information']) ? $payment['information'] : '',
    '#format' => isset($payment['format']) ? $payment['format'] : 'plain_text',
  );
  if (module_exists('token')) {
    $form['token_tree'] = array(
      '#theme' => 'token_tree',
      '#token_types' => array(
        'site',
        'commerce_order',
        'commerce-order',
      ),
      '#dialog' => TRUE,
    );
  }
  $form['status'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enabled'),
    '#description' => t('Disable or enable the default payment method.'),
    '#default_value' => isset($payment['status']) ? $payment['status'] : FALSE,
  );
  $form['checkout'] = array(
    '#type' => 'checkbox',
    '#title' => t('Available on checkout'),
    '#description' => t('TRUE or FALSE indicating whether or not payments can be processed via this payment method through the checkout form.'),
    '#default_value' => isset($payment['checkout']) ? $payment['checkout'] : TRUE,
  );
  $form['terminal'] = array(
    '#type' => 'checkbox',
    '#title' => t('Available on terminal'),
    '#description' => t("TRUE or FALSE indicating whether or not payments can be processed via this payment method through the administrative payment terminal on an order's Payment tab"),
    '#default_value' => isset($payment['terminal']) ? $payment['terminal'] : TRUE,
  );
  if (module_exists('commerce_payment_fields')) {
    $form['fieldable'] = array(
      '#type' => 'checkbox',
      '#title' => t('Payment transaction fieldable'),
      '#description' => t("TRUE or FALSE indicating whether or not payment transactions could be extended with fields"),
      '#default_value' => isset($payment['fieldable']) ? $payment['fieldable'] : FALSE,
    );
  }
  $form['actions']['save'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  return $form;
}