You are here

function pay_form in Pay 7

Same name and namespace in other branches
  1. 6 pay.module \pay_form()

A simple form any type of pay element. If you want to build a module with a standalone payment form, you would do so by passing this function to the drupal_get_form page handler in your hook_menu() funcion.

Alternatively, you can manually add payment form capabilities by including the code from this function in your form builder or form_alter code.

TODO Rename this function as to not collide with hook_form().

1 call to pay_form()
pay_node_pay_form in modules/pay_node/pay_node.module
A callback for node/x/pay which presents a payment form.
16 string references to 'pay_form'
pay::permissions_settings in includes/handlers/pay.inc
pay_admin_pay_form_list in includes/pay.admin.inc
List payment forms
pay_form_load in ./pay.module
API Function: Load a payment form object.
pay_handler_field_amount::query in includes/views/pay_handler_field_amount.inc
Called to add the field to a query.
pay_handler_field_count::query in includes/views/pay_handler_field_count.inc
Called to add the field to a query.

... See full list

File

./pay.module, line 350
Pay module allows for accepting payments using pluggable payment backends.

Code

function pay_form($form, &$form_state, $pay, $type = NULL, $form_type = 'default') {
  if ($type) {
    $pay = pay_load_object($type, $pay);
  }

  // Add a "build mode" to $form_state so that the form handlers can render
  // forms differently based on user-defined context.
  $form_state['pay_form_type'] = $form_type;

  // Allow this handler to alter in all of its form fields. This will also
  // add the appropriate validate and submit callbacks for the Payment API.
  $pay
    ->form($form, $form_state);

  // Add a submit button, if we think it's necessary.
  if (!isset($form['submit']) && !isset($form[$pay
    ->handler()]['submit'])) {
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Submit payment'),
    );
  }
  return $form;
}