You are here

function drupal_validate_form in Drupal 4

Same name and namespace in other branches
  1. 5 includes/form.inc \drupal_validate_form()
  2. 6 includes/form.inc \drupal_validate_form()
  3. 7 includes/form.inc \drupal_validate_form()

Related topics

3 calls to drupal_validate_form()
comment_form_add_preview in modules/comment.module
drupal_get_form in includes/form.inc
Processes a form array and produces the HTML output of a form. If there is input in the $_POST['edit'] variable, this function will attempt to validate it, using drupal_validate_form(), and then submit the form using drupal_submit_form().
node_form_add_preview in modules/node.module

File

includes/form.inc, line 180

Code

function drupal_validate_form($form_id, $form, $callback = NULL) {
  global $form_values;
  static $validated_forms = array();
  if (isset($validated_forms[$form_id])) {
    return;
  }

  // Check whether the form token is valid.
  if (isset($form['#token'])) {
    if (!drupal_valid_token($form_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.'));
    }
  }
  _form_validate($form, $form_id);
  $validated_forms[$form_id] = TRUE;
}