drupal_validate_form

  1. drupal
    1. 4.7
    2. 5
    3. 6 form.inc
    4. 7 form.inc
Versions
4.7 drupal_validate_form($form_id, $form, $callback = NULL)
5 drupal_validate_form($form_id, $form)
6 drupal_validate_form($form_id, $form, &$form_state)
7 drupal_validate_form($form_id, &$form, &$form_state)

Related topics

▾ 3 functions call 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

Code

includes/form.inc, line 181

<?php
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;
}
?>