You are here

function commerce_payment_ui_form_commerce_payment_ui_add_payment_rule_form_alter in Commerce Core 7

Implements hook_form_FORM_ID_alter().

The Payment UI module instantiates the Rules Admin rule configuration add form at a particular path in the Commerce IA. It uses its own form ID to do so and alters the form here to select the necessary Rules event. It also lets the user specify which payment method to enable through the Rule.

See also

commerce_payment_ui_add_payment_rule_form_submit()

rules_admin_add_reaction_rule()

File

modules/payment/commerce_payment_ui.module, line 232
Default Payment UI for Drupal Commerce.

Code

function commerce_payment_ui_form_commerce_payment_ui_add_payment_rule_form_alter(&$form, &$form_state) {
  unset($form['settings']['help']);
  $form['settings']['event']['#type'] = 'value';
  $form['settings']['event']['#value'] = 'commerce_payment_methods';
  $form['method_id'] = array(
    '#type' => 'select',
    '#title' => t('Payment method'),
    '#options' => commerce_payment_method_get_title(),
    '#required' => TRUE,
  );

  // Add function call to the beginning of the submit callback array
  array_unshift($form['#submit'], 'commerce_payment_ui_add_payment_rule_form_submit');
  $form['submit']['#suffix'] = l(t('Cancel'), 'admin/commerce/config/payment-methods');
}