Index: includes/form.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/form.inc,v retrieving revision 1.129 diff -u -r1.129 form.inc --- includes/form.inc 19 Jul 2006 07:25:49 -0000 1.129 +++ includes/form.inc 20 Jul 2006 16:54:07 -0000 @@ -1,5 +1,5 @@ uid && $_SERVER['REQUEST_METHOD'] == 'GET') { unset($form['#token']); } @@ -121,55 +138,8 @@ } $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); - // IE does not send a button value when there is only one submit button (and no non-submit buttons) - // and you submit by pressing enter. - // In that case we accept a submission without button values. - if (($form_submitted || (!$form_button_counter[0] && $form_button_counter[1])) && !form_get_errors()) { - $redirect = drupal_submit_form($form_id, $form, $callback); - if (isset($redirect)) { - $goto = $redirect; - } - if (isset($form['#redirect'])) { - $goto = $form['#redirect']; - } - if ($goto !== FALSE) { - if (is_array($goto)) { - call_user_func_array('drupal_goto', $goto); - } - elseif (!isset($goto)) { - drupal_goto($_GET['q']); - } - else { - drupal_goto($goto); - } - } - } - } - - // Don't override #theme if someone already set it. - if (!isset($form['#theme'])) { - if (theme_get_function($form_id)) { - $form['#theme'] = $form_id; - } - elseif (theme_get_function($callback)) { - $form['#theme'] = $callback; - } - } - - if (isset($form['#pre_render'])) { - foreach ($form['#pre_render'] as $function) { - if (function_exists($function)) { - $function($form_id, $form); - } - } - } - - $output = form_render($form); - // Restore globals - list($form_values, $form_submitted, $form_button_counter) = array_pop($saved_globals); - return $output; + + return $form; } function drupal_validate_form($form_id, $form, $callback = NULL) { @@ -210,6 +180,49 @@ return $goto; } +function drupal_render_form($form_id, &$form, $callback = NULL) { + // Don't override #theme if someone already set it. + if (!isset($form['#theme'])) { + if (theme_get_function($form_id)) { + $form['#theme'] = $form_id; + } + elseif (theme_get_function($callback)) { + $form['#theme'] = $callback; + } + } + + if (isset($form['#pre_render'])) { + foreach ($form['#pre_render'] as $function) { + if (function_exists($function)) { + $function($form_id, $form); + } + } + } + + $output = form_render($form); + return $output; +} + +function drupal_redirect_form($form, $redirect = NULL) { + if (isset($redirect)) { + $goto = $redirect; + } + if (isset($form['#redirect'])) { + $goto = $form['#redirect']; + } + if ($goto !== FALSE) { + if (is_array($goto)) { + call_user_func_array('drupal_goto', $goto); + } + elseif (!isset($goto)) { + drupal_goto($_GET['q']); + } + else { + drupal_goto($goto); + } + } +} + function _form_validate($elements, $form_id = NULL) { // Recurse through all children. foreach (element_children($elements) as $key) {