You are here

function payment_element_info in Payment 7

Implements hook_element_info().

File

./payment.module, line 622
Hook implementations and shared functions.

Code

function payment_element_info() {

  // A payment method selection and configuration element. Every form this
  // element is used in should have a Payment object in $form_state['payment'].
  $elements['payment_method'] = array(
    '#input' => TRUE,
    '#process' => array(
      'payment_form_process_method',
    ),
    '#element_validate' => array(
      'payment_form_process_method_validate',
    ),
    // An array with IDs of the allowed payment methods. Leave empty to allow
    // all. If just a single value is given, or if only ony payment method is
    // valid, the element will not expand to a select list, but will appear to
    // the user as if there only is one payment method available at all.
    '#pmids' => array(),
  );

  // An element to collect a payment amount and convert it to a float.
  $elements['payment_amount'] = array(
    '#input' => TRUE,
    '#process' => array(
      'payment_form_process_amount',
    ),
    '#element_validate' => array(
      'payment_form_process_amount_validate',
    ),
    // The minimum payment amount as a float that needs to be entered. Use
    // FALSE to omit.
    '#minimum_amount' => FALSE,
    // The ISO 4217 currency code.
    '#currency_code' => 'XXX',
  );

  // Line item configuration. The element's #default_value is an array with
  // PaymentLineItem objects.
  $elements['payment_line_item'] = array(
    '#input' => TRUE,
    '#tree' => TRUE,
    '#process' => array(
      'payment_form_process_line_item',
    ),
    '#attached' => array(
      'css' => array(
        drupal_get_path('module', 'payment') . '/css/payment.css',
      ),
    ),
    '#element_validate' => array(
      'payment_form_process_line_item_validate',
    ),
    // The ISO 4217 currency code.
    '#currency_code' => 'XXX',
    // The number of values this element allows. Enter 0 for unlimited.
    '#cardinality' => 0,
  );

  // Placeholder element for a payment method controller's payment or payment
  // method form elements callback. Using this element ensures the callbacks
  // receive enough contextual information.
  $elements['payment_form_context'] = array(
    '#tree' => TRUE,
    '#process' => array(
      'payment_form_process_context',
    ),
    // The class name of the payment method controller whose callbacks to call.
    '#payment_method_controller_name' => '',
    // Either "payment" or "payment_method".
    '#callback_type' => '',
  );
  return $elements;
}