You are here

function pay_admin_method_form in Pay 6

Same name and namespace in other branches
  1. 7 includes/pay.admin.inc \pay_admin_method_form()

Admin form to create or update payment methods.

1 string reference to 'pay_admin_method_form'
pay_menu_menu in includes/pay.menu.inc
Implementation of hook_menu().

File

includes/pay.admin.inc, line 159
Administration form settings and related functions.

Code

function pay_admin_method_form(&$form_state, $pay_method = NULL) {
  if (isset($form_state['storage']['pay_method'])) {
    $pay_method = $form_state['storage']['pay_method'];
  }
  if ($pay_method) {
    $form = array();
    if (!is_object($pay_method)) {
      $pay_method = pay_method_load($pay_method);
    }
    $pay_method
      ->settings_form($form, $form_state);
    $pmid = isset($pay_method->pmid) ? $pay_method->pmid : get_class($pay_method);
    $form['#pay_method'] = $pmid;
  }
  else {
    $form['pay_method'] = array(
      '#type' => 'radios',
      '#title' => t('Payment handler'),
    );
    foreach (pay_handlers('pay_method') as $name => $info) {
      if (!$info['title']) {
        continue;
      }

      // Exclude unnamed base classes.
      $form['pay_method'][$name] = array(
        '#type' => 'radio',
        '#name' => 'pay_method',
        '#title' => $info['title'],
        '#description' => $info['description'],
        '#return_value' => $name,
      );
    }
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save values'),
  );

  // Vertical tab-ify this form if vertical_tabs module is installed.
  $form['#pre_render'][] = 'vertical_tabs_form_pre_render';
  return $form;
}