From c3cb1ea435b34ab1ef6b074774528a5226b5e884 Mon Sep 17 00:00:00 2001
From: Gerhard Killesreiter <killes_www_drop_org@227.no-reply.drupal.org>
Date: Thu, 6 Apr 2006 15:30:19 +0000
Subject: [PATCH] #56921, revert earlier patches, patch by chx

---
 includes/form.inc            | 10 ++++++----
 modules/poll.module          |  2 +-
 modules/poll/poll.module     |  2 +-
 modules/upload.module        |  2 +-
 modules/upload/upload.module |  2 +-
 5 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/includes/form.inc b/includes/form.inc
index 61563169d866..c0b61b661d3a 100644
--- a/includes/form.inc
+++ b/includes/form.inc
@@ -111,8 +111,7 @@ function drupal_get_form($form_id, &$form, $callback = NULL) {
     $function($form_id, $form);
   }
 
-  form_builder($form_id, $form);
-
+  $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()) {
@@ -308,9 +307,10 @@ 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 */
   if ((!empty($form['#type'])) && ($info = _element_info($form['#type']))) {
     // overlay $info onto $form, retaining preexisting keys in $form
@@ -417,7 +417,7 @@ function form_builder($form_id, &$form) {
     if (!isset($form[$key]['#weight'])) {
       $form[$key]['#weight'] = $count/1000;
     }
-    form_builder($form_id, $form[$key]);
+    $form[$key] = form_builder($form_id, $form[$key]);
     $count++;
   }
 
@@ -426,6 +426,8 @@ function form_builder($form_id, &$form) {
     $form = $function($form, $form_values);
     $form['#after_build_done'] = TRUE;
   }
+
+  return $form;
 }
 
 /**
diff --git a/modules/poll.module b/modules/poll.module
index 7c16ee3521c3..1087f742fb57 100644
--- a/modules/poll.module
+++ b/modules/poll.module
@@ -133,7 +133,7 @@ function poll_form(&$node) {
 
   $form['choice']['choices'] = array('#type' => 'hidden', '#default_value' => max(2, count($node->choice) ? count($node->choice) : 5));
   $form['choice']['morechoices'] = array('#type' => 'checkbox', '#title' => t('Need more choices'), '#default_value' => 0, '#description' => t("If the amount of boxes above isn't enough, check this box and click the Preview button below to add some more."), '#weight' => 1);
-  form_builder('poll_node_form', $form['choice']);
+  $form['choice'] = form_builder('poll_node_form', $form['choice']);
   if ($form['choice']['morechoices']['#value']) {
     $form['choice']['morechoices']['#value'] = 0;
     $form['choice']['choices']['#value'] *= 2;
diff --git a/modules/poll/poll.module b/modules/poll/poll.module
index 7c16ee3521c3..1087f742fb57 100644
--- a/modules/poll/poll.module
+++ b/modules/poll/poll.module
@@ -133,7 +133,7 @@ function poll_form(&$node) {
 
   $form['choice']['choices'] = array('#type' => 'hidden', '#default_value' => max(2, count($node->choice) ? count($node->choice) : 5));
   $form['choice']['morechoices'] = array('#type' => 'checkbox', '#title' => t('Need more choices'), '#default_value' => 0, '#description' => t("If the amount of boxes above isn't enough, check this box and click the Preview button below to add some more."), '#weight' => 1);
-  form_builder('poll_node_form', $form['choice']);
+  $form['choice'] = form_builder('poll_node_form', $form['choice']);
   if ($form['choice']['morechoices']['#value']) {
     $form['choice']['morechoices']['#value'] = 0;
     $form['choice']['choices']['#value'] *= 2;
diff --git a/modules/upload.module b/modules/upload.module
index 2bc04249750e..a523d5ab9a18 100644
--- a/modules/upload.module
+++ b/modules/upload.module
@@ -640,7 +640,7 @@ function upload_js() {
   _upload_validate($node);
 
   $form = _upload_form($node);
-  form_builder('upload_js', $form);
+  $form = form_builder('upload_js', $form);
   $output = theme('status_messages') . form_render($form);
 
   // We send the updated file attachments form.
diff --git a/modules/upload/upload.module b/modules/upload/upload.module
index 2bc04249750e..a523d5ab9a18 100644
--- a/modules/upload/upload.module
+++ b/modules/upload/upload.module
@@ -640,7 +640,7 @@ function upload_js() {
   _upload_validate($node);
 
   $form = _upload_form($node);
-  form_builder('upload_js', $form);
+  $form = form_builder('upload_js', $form);
   $output = theme('status_messages') . form_render($form);
 
   // We send the updated file attachments form.
-- 
GitLab