Commit 352fb57d authored by drumm's avatar drumm
Browse files

#56921 by chx, removing the $form = from $form = form_builder($form_id, $form) then it works.

parent 1a7a63b0
......@@ -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;
}
/**
......
......@@ -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['choice'] = form_builder('poll_node_form', $form['choice']);
form_builder('poll_node_form', $form['choice']);
if ($form['choice']['morechoices']['#value']) {
$form['choice']['morechoices']['#value'] = 0;
$form['choice']['choices']['#value'] *= 2;
......
......@@ -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['choice'] = form_builder('poll_node_form', $form['choice']);
form_builder('poll_node_form', $form['choice']);
if ($form['choice']['morechoices']['#value']) {
$form['choice']['morechoices']['#value'] = 0;
$form['choice']['choices']['#value'] *= 2;
......
......@@ -640,7 +640,7 @@ function upload_js() {
_upload_validate($node);
$form = _upload_form($node);
$form = form_builder('upload_js', $form);
form_builder('upload_js', $form);
$output = theme('status_messages') . form_render($form);
// We send the updated file attachments form.
......
......@@ -640,7 +640,7 @@ function upload_js() {
_upload_validate($node);
$form = _upload_form($node);
$form = form_builder('upload_js', $form);
form_builder('upload_js', $form);
$output = theme('status_messages') . form_render($form);
// We send the updated file attachments form.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment