From be7bb9be9bb41c83795fa8d7fa119ce4025f2de0 Mon Sep 17 00:00:00 2001
From: Dries Buytaert <dries@buytaert.net>
Date: Tue, 16 May 2006 10:11:19 +0000
Subject: [PATCH] - Patch #63704 by chx: fixed the order of validation.  (Needs
 more wide-spread testing before being backported to DRUPAL-4-7.)

---
 includes/form.inc | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/includes/form.inc b/includes/form.inc
index 310270112345..5e75326fffc2 100644
--- a/includes/form.inc
+++ b/includes/form.inc
@@ -197,6 +197,12 @@ function drupal_submit_form($form_id, $form, $callback = NULL) {
 }
 
 function _form_validate($elements, $form_id = NULL) {
+  // Recurse through all children.
+  foreach (element_children($elements) as $key) {
+    if (isset($elements[$key]) && $elements[$key]) {
+      _form_validate($elements[$key]);
+    }
+  }
   /* Validate the current input */
   if (!$elements['#validated']) {
     if (isset($elements['#needs_validation'])) {
@@ -246,13 +252,6 @@ function _form_validate($elements, $form_id = NULL) {
     }
     $elements['#validated'] = TRUE;
   }
-
-  // Recurse through all children.
-  foreach (element_children($elements) as $key) {
-    if (isset($elements[$key]) && $elements[$key]) {
-      _form_validate($elements[$key]);
-    }
-  }
 }
 
 /**
-- 
GitLab