You are here

function wfm_validate in Webform Multiple (WFM) 7

Validation callback for the webform, running before Webform callbacks.

1 string reference to 'wfm_validate'
wfm_form_webform_client_form_alter in ./wfm.module
Implements hook_form_FORM_ID_alter().

File

./wfm.module, line 405
Main module file for Webform Multiple (WFM).

Code

function wfm_validate($form, &$form_state) {
  $node = $form['#node'];
  $components = $node->webform['components'];

  // Bypass validation if #limit_validation_errors is an empty array.
  if (isset($form_state['triggering_element']['#limit_validation_errors']) && !count($form_state['triggering_element']['#limit_validation_errors'])) {
    return;
  }

  // Prepare the $form_state so it can be processed by the Webform validator,
  // and save the values in their original form because they may be needed
  // later.
  if (isset($form_state['values']['submitted'])) {
    $original_submitted = $form_state['values']['submitted'];
    _wfm_values_prepare($form_state, $components);
  }

  // Run the Webform validator.
  webform_client_form_validate($form, $form_state);

  // If the form needs to be rebuilt, for example if there were validation
  // errors, then reset the $form_state array to its original structure (the
  // structure it had before _wfm_values_prepare() was run).
  if (isset($original_submitted) && (form_get_errors() || !empty($form_state['rebuild']))) {
    $form_state['values']['submitted'] = $original_submitted;
  }
}