From 352fb57d6cd6ced74f78a87c8e40a2d548b15927 Mon Sep 17 00:00:00 2001 From: Neil Drumm Date: Sun, 2 Apr 2006 23:14:51 +0000 Subject: #56921 by chx, removing the $form = from $form = form_builder($form_id, $form) then it works. --- includes/form.inc | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'includes') diff --git a/includes/form.inc b/includes/form.inc index e11277391..170cfc35b 100644 --- a/includes/form.inc +++ b/includes/form.inc @@ -111,7 +111,8 @@ function drupal_get_form($form_id, &$form, $callback = NULL) { $function($form_id, $form); } - $form = form_builder($form_id, $form); + form_builder($form_id, $form); + if (!empty($_POST['edit']) && (($_POST['edit']['form_id'] == $form_id) || ($_POST['edit']['form_id'] == $callback))) { drupal_validate_form($form_id, $form, $callback); if ($form_submitted && !form_get_errors()) { @@ -157,15 +158,6 @@ function drupal_get_form($form_id, &$form, $callback = NULL) { function drupal_validate_form($form_id, &$form, $callback = NULL) { global $form_values; - // we need a copy of form_values otherwise foreach falls into an infite loop - $copy = (array)$form_values; - // this loop breaks the references in form_values thus makes it impossible for - // validate functions to modify the $form_values array - foreach ($copy as $k => $v) { - unset($form_values[$k]); - $form_values[$k] = $v; - } - if (isset($form['#token'])) { if ($form_values['form_token'] != md5(session_id() . $form['#token'] . variable_get('drupal_private_key', ''))) { // setting this error will cause the form to fail validation @@ -316,7 +308,7 @@ function form_error(&$element, $message = '') { * @param $form * An associative array containing the structure of the form. */ -function form_builder($form_id, $form) { +function form_builder($form_id, &$form) { global $form_values; global $form_submitted; /* Use element defaults */ @@ -425,7 +417,7 @@ function form_builder($form_id, $form) { if (!isset($form[$key]['#weight'])) { $form[$key]['#weight'] = $count/1000; } - $form[$key] = form_builder($form_id, $form[$key]); + form_builder($form_id, $form[$key]); $count++; } @@ -434,8 +426,6 @@ function form_builder($form_id, $form) { $form = $function($form, $form_values); $form['#after_build_done'] = TRUE; } - - return $form; } /** -- cgit v1.2.3