You are here

function payment_form_payment_method in Payment 7

Implements form build callback: the payment method add/edit form.

Parameters

PaymentMethod $payment_method:

See also

payment_forms()

3 string references to 'payment_form_payment_method'
payment_menu in ./payment.module
Implements hook_menu().
payment_method_form_add in ./payment.ui.inc
Create a blank payment method and return its payment form.
payment_page_method_clone in ./payment.ui.inc
Clone a payment method and return its payment form.

File

./payment.ui.inc, line 334
The Payment user interface.

Code

function payment_form_payment_method(array $form, array &$form_state, PaymentMethod $payment_method) {
  global $user;
  $form_state['payment_method'] = $payment_method;
  $form['controller'] = array(
    '#type' => 'item',
    '#title' => t('Type'),
    '#markup' => $payment_method->controller->title,
  );
  $form['enabled'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enabled'),
    '#default_value' => $payment_method->enabled,
  );
  $form['title_specific'] = array(
    '#type' => 'textfield',
    '#title' => t('Title (specific)'),
    '#description' => t('The specific title is often only displayed to people such as administrators who need to know the exact payment method that is used, for instance <em>Paypal Website Payments Pro</em>.'),
    '#default_value' => $payment_method->title_specific,
    '#maxlength' => 255,
    '#required' => TRUE,
  );
  $form['name'] = array(
    '#type' => 'machine_name',
    '#default_value' => $payment_method->name,
    '#maxlength' => 255,
    '#required' => TRUE,
    '#machine_name' => array(
      'source' => array(
        'title_specific',
      ),
      'exists' => 'payment_method_name_exists',
    ),
    '#disabled' => !empty($payment_method->pmid),
  );
  $form['title_generic'] = array(
    '#type' => 'textfield',
    '#title' => t('Title (generic)'),
    '#description' => t('The generic title is often only displayed to people such as payers who only need to know the generic payment method that is used, for instance <em>Paypal</em>. Defaults to the specific title.'),
    '#default_value' => $payment_method->title_generic,
    '#maxlength' => 255,
  );
  $form['owner'] = array(
    '#type' => 'textfield',
    '#title' => t('Owner'),
    '#default_value' => $payment_method->uid ? user_load($payment_method->uid)->name : $user->name,
    '#maxlength' => 255,
    '#autocomplete_path' => 'user/autocomplete',
    '#required' => TRUE,
  );
  $form['controller_form'] = array(
    '#type' => 'payment_form_context',
    '#payment_method_controller_name' => $payment_method->controller->name,
    '#callback_type' => 'payment_method',
  );
  $form['actions'] = array(
    '#type' => 'actions',
  );
  $form['actions']['save'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  if ($payment_method->pmid) {
    $form['actions']['delete'] = array(
      '#type' => 'link',
      '#title' => t('Delete'),
      '#href' => 'admin/config/services/payment/method/' . $payment_method->pmid . '/delete',
      '#access' => payment_method_access('delete', $payment_method),
    );
  }
  return $form;
}