You are here

function payment_form_process_method_validate in Payment 7

Implements form validate callback for a payment_method element.

1 string reference to 'payment_form_process_method_validate'
payment_element_info in ./payment.module
Implements hook_element_info().

File

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

Code

function payment_form_process_method_validate(array $element, array &$form_state) {
  $pmid = drupal_array_get_nested_value($form_state['values'], array_merge($element['#parents'], array(
    'pmid',
  )));
  if ($pmid) {
    $payment = $form_state['payment'];

    // Another payment method was selected, so rebuild the form.
    if (!$payment->method || $payment->method->pmid != $pmid) {
      $payment->method = entity_load_single('payment_method', $pmid);
      $form_state['rebuild'] = TRUE;
    }
  }
}