drupal_validate_form

Versions
4.7
drupal_validate_form($form_id, $form, $callback = NULL)
5
drupal_validate_form($form_id, $form)
6 – 7
drupal_validate_form($form_id, $form, &$form_state)

▾ 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 180

<?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;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.