| Versions | |
|---|---|
| 4.7 | drupal_validate_form($form_id, $form, |
| 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) |
includes/
<?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;
}
?>