diff options
author | Steven Wittens <steven@10.no-reply.drupal.org> | 2005-11-12 03:45:57 +0000 |
---|---|---|
committer | Steven Wittens <steven@10.no-reply.drupal.org> | 2005-11-12 03:45:57 +0000 |
commit | 36b62d969d0b9aa71091ba561760992ca1d5e1e6 (patch) | |
tree | 2334a749b9ce8e8ddfebf983f307bbc87e8f0136 | |
parent | 85492ae9a548f0bfb58b673ac555f73d4b7977ed (diff) | |
download | brdo-36b62d969d0b9aa71091ba561760992ca1d5e1e6.tar.gz brdo-36b62d969d0b9aa71091ba561760992ca1d5e1e6.tar.bz2 |
#37078: forms api does not respect form_id when populating from ['edit'] or validating
-rw-r--r-- | includes/form.inc | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/includes/form.inc b/includes/form.inc index 6b3dbb192..a32d14259 100644 --- a/includes/form.inc +++ b/includes/form.inc @@ -71,9 +71,9 @@ function drupal_get_form($form_id, &$form, $callback = NULL) { $function($form_id, $form); } - $form = _form_builder($form); + $form = _form_builder($form_id, $form); - if (!empty($_POST['edit']) && (($form_values['form_id'] == $form_id) || ($form_values['form_id'] == $callback))) { + if (!empty($_POST['edit']) && (($_POST['edit']['form_id'] == $form_id) || ($_POST['edit']['form_id'] == $callback))) { drupal_validate_form($form_id, $form, $callback); if ($form_execute && !form_get_errors()) { drupal_execute_form($form_id, $form, $callback); @@ -215,7 +215,7 @@ function form_error(&$element, $message) { * This function also automatically assigns the value property from the $edit array, provided the * element doesn't already have an assigned value. */ -function _form_builder($form) { +function _form_builder($form_id, $form) { global $form_values; global $form_execute; /* Use element defaults */ @@ -227,7 +227,7 @@ function _form_builder($form) { $form['#name'] = ($form['#name']) ? $form['#name'] : 'edit[' . implode('][', $form['#parents']) . ']'; $form['#id'] = ($form['#id']) ? $form['#id'] : 'edit-' . implode('-', $form['#parents']); - $posted = isset($_POST['edit']); + $posted = (isset($_POST['edit']) && ($_POST['edit']['form_id'] == $form_id)); $edit = $posted ? $_POST['edit'] : array(); $ref =& $form_values; foreach ($form['#parents'] as $parent) { @@ -289,7 +289,7 @@ function _form_builder($form) { # Assign a decimal placeholder weight, to preserve original array order $form[$key]['#weight'] = $form[$key]['#weight'] ? $form[$key]['#weight'] : $count/1000; - $form[$key] = _form_builder($form[$key]); + $form[$key] = _form_builder($form_id, $form[$key]); $count++; } |