Index: form.inc =================================================================== --- form.inc (revision 39) +++ form.inc (working copy) @@ -584,19 +584,45 @@ } } + + /** + * Set the static variable to the array. + * This is nice because we can still have the static array, but it allows + * people who need to reset it, the ability to reset it + */ +function _form_set_error_array($array = null) { + static $form = array(); + + if (isset($array)) { + $form = $array; + } + + return $form; +} + + /** + * Resets the errors for this form. + */ +function form_reset_errors() { + _form_set_error_array(array()); +} + + +/** * File an error against a form element. If the name of the element is * edit[foo][bar] then you may pass either foo or foo][bar as $name * foo will set an error for all its children. */ function form_set_error($name = NULL, $message = '') { - static $form = array(); + $form = _form_set_error_array(); if (isset($name) && !isset($form[$name])) { $form[$name] = $message; if ($message) { drupal_set_message($message, 'error'); } } + $form = _form_set_error_array($form); return $form; } @@ -604,7 +630,7 @@ * Return an associative array of all errors. */ function form_get_errors() { - $form = form_set_error(); + $form = _form_set_error_array(); if (!empty($form)) { return $form; } @@ -614,7 +640,7 @@ * Return the error message filed against the form with the specified name. */ function form_get_error($element) { - $form = form_set_error(); + $form = _form_set_error_array(); $key = $element['#parents'][0]; if (isset($form[$key])) { return $form[$key];