You are here

function ctools_validate_form in Chaos Tool Suite (ctools) 6

The original version of drupal_validate_form does not have an override for the static check to only validate a form id once. Unfortunately, we need to be able to override this.

1 call to ctools_validate_form()
ctools_process_form in includes/form.inc
ctools' replacement for drupal_process_form that accepts commands not to redirect, as well as forcing processing of 'get' method forms.

File

includes/form.inc, line 310
CTools' replacements for Drupal's form functions.

Code

function ctools_validate_form($form_id, $form, &$form_state) {
  static $validated_forms = array();
  if (isset($validated_forms[$form_id]) && empty($form_state['must_validate'])) {
    return;
  }

  // If the session token was set by drupal_prepare_form(), ensure that it
  // matches the current user's session.
  if (isset($form['#token'])) {
    if (!drupal_valid_token($form_state['values']['form_token'], $form['#token'])) {

      // Setting this error will cause the form to fail validation.
      form_set_error('form_token', t('Validation error, please try again. If this error persists, please contact the site administrator.'));
    }
  }
  if (!empty($form_state['clicked_button']['#skip validation'])) {
    return;
  }
  _form_validate($form, $form_state, $form_id);
  $validated_forms[$form_id] = TRUE;
}