=== added file 'form_update.txt' --- /dev/null +++ form_update.txt @@ -0,0 +1,70 @@ +If you had a page which only contained a form: + + + +then just change it to: + + + +If you used another form_id or a callback (which is now called function_prefix): + + + +that becomes: + + + +Finally, if you had a page which contained a form and other things, then you need to move the form to a separate function: + + + +then you will need: + + + +Finally, system_settings_form now just needs an array, remove the +form_id. === modified file 'includes/form.inc' --- includes/form.inc +++ includes/form.inc @@ -20,20 +20,41 @@ * will attempt to validate it, using drupal_validate_form(), * and then submit the form using drupal_submit_form(). * - * @param $form_id - * A unique string identifying the form. Allows each form to be - * themed. Pass NULL to suppress the form_id parameter (produces - * a shorter URL with method=get) - * @param $form - * An associative array containing the structure of the form. - * @param $callback - * An optional callback that will be used in addition to the form_id. - * + * @param $form_handler + * A unique string identifying the form in the array returned from + * hook_forms. + * @param ... + * Any number of arguments passed to the form handler. */ -function drupal_get_form($form_id, &$form, $callback = NULL) { +function drupal_get_form($form_handler) { + static $forms; + + $args = func_get_args(); + $form_handler = array_shift($args); + if (!function_exists($form_handler)) { + if (!isset($forms)) { + $forms = module_invoke_all('forms'); + } + $form_definition = $forms[$form_handler]; + if (isset($form_definition['callback arguments'])) { + $args = array_merge($form_definition['callback arguments'], $args); + } + if (isset($form_definition['callback'])) { + $callback = $form_definition['callback']; + } + } + $form = call_user_func_array(isset($callback) ? $callback : $form_handler, $args); + return drupal_process_form($form_handler, $form); +} + +function drupal_process_form($form_handler, $form) { global $form_values, $form_submitted, $user, $form_button_counter; static $saved_globals = array(); + $form_id = isset($form['#form_id']) ? $form['#form_id'] : $form_handler; + if (isset($form['#function_prefix'])) { + $function_prefix = $form['#function_prefix']; + } // Save globals in case of indirect recursive call array_push($saved_globals, array($form_values, $form_submitted, $form_button_counter)); @@ -41,20 +62,20 @@ function drupal_get_form($form_id, &$for $form_submitted = FALSE; $form_button_counter = array(0, 0); - $form = drupal_build_form($form_id, $form, $callback); + $form = drupal_build_form($form_id, $form, $function_prefix); - if (!empty($_POST['edit']) && (($_POST['edit']['form_id'] == $form_id) || ($_POST['edit']['form_id'] == $callback))) { - drupal_validate_form($form_id, $form, $callback); + if (!empty($_POST['edit']) && (($_POST['edit']['form_id'] == $form_id) || ($_POST['edit']['form_id'] == $function_prefix))) { + drupal_validate_form($form_id, $form); // 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); + $redirect = drupal_submit_form($form_id, $form); drupal_redirect_form($form, $redirect); } } - $output = drupal_render_form($form_id, $form, $callback); + $output = drupal_render_form($form_id, $form, $function_prefix); list($form_values, $form_submitted, $form_button_counter) = array_pop($saved_globals); return $output; } @@ -69,11 +90,11 @@ function drupal_get_form($form_id, &$for * theming, and hook_form_alter functions. * @param $form * An associative array containing the structure of the form. - * @param $callback - * An optional callback that will be used in addition to the form_id. + * @param $function_prefix + * An optional function prefix that will be used in place of $form_id. * */ -function drupal_build_form($form_id, &$form, $callback = NULL) { +function drupal_build_form($form_id, &$form, $function_prefix = NULL) { $form['#type'] = 'form'; if (isset($form['#token'])) { // If the page cache is on and an anonymous user issues a GET request, @@ -105,8 +126,8 @@ function drupal_build_form($form_id, &$f if (function_exists($form_id .'_validate')) { $form['#validate'] = array($form_id .'_validate' => array()); } - elseif (function_exists($callback .'_validate')) { - $form['#validate'] = array($callback .'_validate' => array()); + elseif (function_exists($function_prefix .'_validate')) { + $form['#validate'] = array($function_prefix .'_validate' => array()); } } @@ -116,8 +137,8 @@ function drupal_build_form($form_id, &$f // $form_values because it will change later $form['#submit'] = array($form_id .'_submit' => array()); } - elseif (function_exists($callback .'_submit')) { - $form['#submit'] = array($callback .'_submit' => array()); + elseif (function_exists($function_prefix .'_submit')) { + $form['#submit'] = array($function_prefix .'_submit' => array()); } } @@ -141,11 +162,9 @@ function drupal_build_form($form_id, &$f * theming, and hook_form_alter functions. * @param $form * An associative array containing the structure of the form. - * @param $callback - * An optional callback that will be used in addition to the form_id. * */ -function drupal_validate_form($form_id, $form, $callback = NULL) { +function drupal_validate_form($form_id, $form) { global $form_values; static $validated_forms = array(); @@ -175,14 +194,12 @@ function drupal_validate_form($form_id, * theming, and hook_form_alter functions. * @param $form * An associative array containing the structure of the form. - * @param $callback - * An optional callback that will be used in addition to the form_id. * @return * A string containing the path of the page to display when processing * is complete. * */ -function drupal_submit_form($form_id, $form, $callback = NULL) { +function drupal_submit_form($form_id, $form) { global $form_values; $default_args = array($form_id, &$form_values); @@ -209,21 +226,21 @@ function drupal_submit_form($form_id, $f * theming, and hook_form_alter functions. * @param $form * An associative array containing the structure of the form. - * @param $callback - * An optional callback that will be used in addition to the form_id. + * @param $function_prefix + * An optional function prefix that will be used in addition to the form_id. * @return * A string containing the path of the page to display when processing * is complete. * */ -function drupal_render_form($form_id, &$form, $callback = NULL) { +function drupal_render_form($form_id, &$form, $function_prefix = 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; + elseif (theme_get_function($function_prefix)) { + $form['#theme'] = $function_prefix; } } === modified file 'includes/menu.inc' --- includes/menu.inc +++ includes/menu.inc @@ -415,7 +415,12 @@ function menu_execute_active_handler() { $arguments = array_merge($arguments, explode('/', $arg)); } - return call_user_func_array($menu['callbacks'][$path]['callback'], $arguments); + $callback = $menu['callbacks'][$path]['callback']; + $return = call_user_func_array($callback, $arguments); + if (is_array($return)) { + return drupal_process_form($callback, $return); + } + return $return; } /** === modified file 'modules/aggregator/aggregator.module' --- modules/aggregator/aggregator.module +++ modules/aggregator/aggregator.module @@ -332,7 +332,7 @@ function aggregator_block($op, $delta = $form['cid'] = array('#type' => 'hidden', '#value' => $edit['cid']); } - return drupal_get_form('aggregator_form_category', $form); + return $form; } /** @@ -463,7 +463,7 @@ function aggregator_form_feed($edit = ar $form['fid'] = array('#type' => 'hidden', '#value' => $edit['fid']); } - return drupal_get_form('aggregator_form_feed', $form); + return $form; } /** @@ -1045,28 +1045,15 @@ function aggregator_page_category() { return _aggregator_page_list('SELECT i.*, f.title AS ftitle, f.link AS flink FROM {aggregator_category_item} c LEFT JOIN {aggregator_item} i ON c.iid = i.iid LEFT JOIN {aggregator_feed} f ON i.fid = f.fid WHERE cid = '. $category->cid .' ORDER BY timestamp DESC, iid DESC', arg(3)); } -/** - * Prints an aggregator page listing a number of feed items. Various - * menu callbacks use this function to print their feeds. - */ -function _aggregator_page_list($sql, $op, $header = '') { - $categorize = (user_access('administer news feeds') && ($op == 'categorize')); - - $output = '
'; - +function aggregator_page_list($sql, $header, $categorize) { $form['header'] = array('#value' => $header); - $output .= $form['header']['#value']; - $result = pager_query($sql, 20); $categories = array(); $done = FALSE; while ($item = db_fetch_object($result)) { $form['items'][$item->iid] = array('#value' => theme('aggregator_page_item', $item)); - $output .= $form['items'][$item->iid]['#value']; $form['categories'][$item->iid] = array(); - if ($categorize) { - $categories_result = db_query('SELECT c.cid, c.title, ci.iid FROM {aggregator_category} c LEFT JOIN {aggregator_category_item} ci ON c.cid = ci.cid AND ci.iid = %d', $item->iid); $selected = array(); while ($category = db_fetch_object($categories_result)) { @@ -1085,11 +1072,8 @@ function _aggregator_page_list($sql, $op ); } } - $output .= '
'; $form['submit'] = array('#type' => 'submit', '#value' => t('Save categories')); $form['pager'] = array('#value' => theme('pager', NULL, 20, 0)); - $output .= $form['pager']['#value']; - // arg(1) is undefined if we are at the top aggregator URL // is there a better way to do this? if (!arg(1)) { @@ -1098,9 +1082,30 @@ function _aggregator_page_list($sql, $op elseif (arg(1) == 'categories' && arg(2) && !arg(3)) { $form['feed_icon'] = array('#value' => theme('feed_icon', url('aggregator/rss/' . arg(2)))); } - $output .= $form['feed_icon']['#value']; + return $form; +} - return ($categorize) ? drupal_get_form('aggregator_page_list', $form) : $output; +/** + * Prints an aggregator page listing a number of feed items. Various + * menu callbacks use this function to print their feeds. + */ +function _aggregator_page_list($sql, $op, $header = '') { + $categorize = (user_access('administer news feeds') && ($op == 'categorize')); + $form = aggregator_page_list($sql, $header, $categorize); + if ($categorize) { + return $form; + } + else { + $output = '
'; + $output .= $header; + foreach ($form['items'] as $item) { + $output .= $item['#value']; + } + $output .= '
'; + $output .= $form['pager']['#value']; + $output .= $form['feed_icon']['#value']; + return $output; + } } function theme_aggregator_page_list($form) { === modified file 'modules/block/block.module' --- modules/block/block.module +++ modules/block/block.module @@ -84,7 +84,7 @@ function block_menu($may_cache) { 'type' => MENU_CALLBACK); $items[] = array('path' => 'admin/build/block/add', 'title' => t('add block'), 'access' => user_access('administer blocks'), - 'callback' => 'block_box_add', + 'callback' => 'block_box_form', 'type' => MENU_LOCAL_TASK); foreach (list_themes() as $key => $theme) { if ($theme->status) { @@ -240,7 +240,7 @@ function block_admin_display($theme = NU } $form['submit'] = array('#type' => 'submit', '#value' => t('Save blocks')); - return drupal_get_form('block_admin_display', $form); + return $form; } /** @@ -463,7 +463,7 @@ function block_admin_configure($module = '#value' => t('Save block'), ); - return drupal_get_form('block_admin_configure', $form); + return $form; } function block_admin_configure_validate($form_id, $form_values) { @@ -488,16 +488,6 @@ function block_admin_configure_submit($f } } -/** - * Menu callback; displays the block creation form. - */ -function block_box_add() { - $form = block_box_form(); - $form['submit'] = array('#type' => 'submit', '#value' => t('Save block')); - - return drupal_get_form('block_box_add', $form); -} - function block_box_add_validate($form_id, $form_values) { if (empty($form_values['info']) || db_num_rows(db_query("SELECT info FROM {boxes} WHERE info = '%s'", $form_values['info']))) { form_set_error('info', t('Please ensure that each block description is unique.')); @@ -562,6 +552,7 @@ function block_box_form($edit = array()) '#weight' => -17, ); $form['body_filter']['format'] = filter_form($edit['format'], -16); + $form['submit'] = array('#type' => 'submit', '#value' => t('Save block')); return $form; } === modified file 'modules/book/book.module' --- modules/book/book.module +++ modules/book/book.module @@ -320,7 +320,7 @@ function book_outline($nid) { } drupal_set_title(check_plain($node->title)); - return drupal_get_form('book_outline', $form); + return $form; } /** @@ -887,7 +887,7 @@ function book_admin_edit($nid) { '#value' => t('Save book pages'), ); - return drupal_get_form('book_admin_edit', $form); + return $form; } else { drupal_not_found(); @@ -915,19 +915,17 @@ function book_admin_orphan() { } if (count($orphans)) { - $form = array(); - $form['table'] = _book_admin_table($orphans); $form['save'] = array( '#type' => 'submit', '#value' => t('Save book pages'), ); - return drupal_get_form('book_admin_edit', $form); } else { - return '

'. t('There are no orphan pages.') .'

'; + $form['error'] = array('#value' => '

'. t('There are no orphan pages.') .'

'); } + return $form; } function book_admin_edit_submit($form_id, $form_values) { === modified file 'modules/comment/comment.module' --- modules/comment/comment.module +++ modules/comment/comment.module @@ -891,7 +891,7 @@ function comment_render($node, $cid = 0) // Start a form, for use with comment control. $result = pager_query($query, $comments_per_page, 0, $query_count, $query_args); if (db_num_rows($result) && (variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE || variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE_BELOW)) { - $output .= comment_controls($mode, $order, $comments_per_page); + $output .= drupal_get_form('comment_controls', $mode, $order, $comments_per_page); } while ($comment = db_fetch_object($result)) { @@ -916,7 +916,7 @@ function comment_render($node, $cid = 0) $output .= theme('pager', NULL, $comments_per_page, 0); if (db_num_rows($result) && (variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_BELOW || variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE_BELOW)) { - $output .= comment_controls($mode, $order, $comments_per_page); + $output .= drupal_get_form('comment_controls', $mode, $order, $comments_per_page); } } @@ -1043,7 +1043,7 @@ function comment_admin_overview($type = } $form['comments'] = array('#type' => 'checkboxes', '#options' => $comments); $form['pager'] = array('#value' => theme('pager', NULL, 50, 0)); - return drupal_get_form('comment_admin_overview', $form); + return $form; } /** @@ -1274,7 +1274,7 @@ function comment_validate($edit) { ** This is rendered by theme_comment_form. */ -function comment_form($edit, $title = NULL) { +function _comment_form($edit, $title = NULL) { global $user; $op = isset($_POST['op']) ? $_POST['op'] : ''; @@ -1421,8 +1421,12 @@ function comment_form($edit, $title = NU // Graft in extra form additions $form = array_merge($form, comment_invoke_comment($form, 'form')); + $form['#form_id'] = 'comment_form'; + return $form; +} - return theme('box', $title, drupal_get_form('comment_form', $form)); +function _comment_form($edit, $title = NULL) { + return theme('box', $title, drupal_get_form('_comment_form', $edit, $title)); } function comment_form_add_preview($form, $edit) { @@ -1575,7 +1579,7 @@ function comment_controls($mode = COMMEN '#weight' => 20, ); - return drupal_get_form('comment_controls', $form); + return $form; } function theme_comment_controls($form) { === modified file 'modules/contact/contact.module' --- modules/contact/contact.module +++ modules/contact/contact.module @@ -199,7 +199,7 @@ function contact_admin_edit($cid = NULL) '#value' => t('Submit'), ); - return drupal_get_form('contact_admin_edit', $form); + return $form; } /** @@ -297,14 +297,7 @@ function contact_admin_settings() { '#default_value' => variable_get('contact_default_status', 1), '#description' => t('Default status of the personal contact form for new users.'), ); - $form['submit'] = array('#type' => 'submit', - '#value' => t('Save configuration'), - ); - $form['reset'] = array('#type' => 'submit', - '#value' => t('Reset to defaults'), - ); - - return drupal_get_form('contact_admin_settings', $form, 'system_settings_form'); + return system_settings_form($form); } /** @@ -322,33 +315,7 @@ function contact_mail_user() { } else { drupal_set_title($account->name); - - $form['#token'] = $user->name . $user->mail; - $form['from'] = array('#type' => 'item', - '#title' => t('From'), - '#value' => $user->name .' <'. $user->mail .'>', - ); - $form['to'] = array('#type' => 'item', - '#title' => t('To'), - '#value' => $account->name, - ); - $form['subject'] = array('#type' => 'textfield', - '#title' => t('Subject'), - '#maxlength' => 50, - '#required' => TRUE, - ); - $form['message'] = array('#type' => 'textarea', - '#title' => t('Message'), - '#rows' => 15, - '#required' => TRUE, - ); - $form['copy'] = array('#type' => 'checkbox', - '#title' => t('Send me a copy.'), - ); - $form['submit'] = array('#type' => 'submit', - '#value' => t('Send e-mail'), - ); - $output = drupal_get_form('contact_mail_user', $form); + $output = drupal_get_form('contact_mail_user_form'); } return $output; @@ -358,6 +325,36 @@ function contact_mail_user() { } } +function contact_mail_user_form() { + $form['#token'] = $user->name . $user->mail; + $form['from'] = array('#type' => 'item', + '#title' => t('From'), + '#value' => $user->name .' <'. $user->mail .'>', + ); + $form['to'] = array('#type' => 'item', + '#title' => t('To'), + '#value' => $account->name, + ); + $form['subject'] = array('#type' => 'textfield', + '#title' => t('Subject'), + '#maxlength' => 50, + '#required' => TRUE, + ); + $form['message'] = array('#type' => 'textarea', + '#title' => t('Message'), + '#rows' => 15, + '#required' => TRUE, + ); + $form['copy'] = array('#type' => 'checkbox', + '#title' => t('Send me a copy.'), + ); + $form['submit'] = array('#type' => 'submit', + '#value' => t('Send e-mail'), + ); + $form['#form_id'] = 'contact_mail_user'; + return $form; +} + /** * Process the personal contact page form submission. */ @@ -416,77 +413,79 @@ function contact_mail_page() { $output = t("You cannot send more than %number messages per hour. Please try again later.", array('%number' => variable_get('contact_hourly_threshold', 3))); } else { - if ($user->uid) { - $edit['name'] = $user->name; - $edit['mail'] = $user->mail; - } + $output = drupal_get_form('contact_mail_page_form'); + } - $result = db_query('SELECT cid, category, selected FROM {contact} ORDER BY weight, category'); - while ($category = db_fetch_object($result)) { - $categories[$category->cid] = $category->category; - if ($category->selected) { - $default_category = $category->cid; - } - } + return $output; +} - if (count($categories) > 0) { - $form['#token'] = $user->name . $user->mail; - $form['contact_information'] = array('#value' => filter_xss_admin(variable_get('contact_form_information', t('You can leave us a message using the contact form below.')))); - $form['name'] = array('#type' => 'textfield', - '#title' => t('Your name'), - '#maxlength' => 255, - '#default_value' => $edit['name'], - '#required' => TRUE, - ); - $form['mail'] = array('#type' => 'textfield', - '#title' => t('Your e-mail address'), - '#maxlength' => 255, - '#default_value' => $edit['mail'], - '#required' => TRUE, - ); - $form['subject'] = array('#type' => 'textfield', - '#title' => t('Subject'), - '#maxlength' => 255, - '#required' => TRUE, - ); - if (count($categories) > 1) { - // If there is more than one category available and no default category has been selected, - // prepend a default placeholder value. - if (!isset($default_category)) { - $categories = array(t('--')) + $categories; - } - $form['cid'] = array('#type' => 'select', - '#title' => t('Category'), - '#default_value' => $default_category, - '#options' => $categories, - '#required' => TRUE, - ); - } - else { - // If there is only one category, store its cid. - $category_keys = array_keys($categories); - $form['cid'] = array('#type' => 'value', - '#value' => array_shift($category_keys), - ); +function contact_mail_page_form() { + global $user; + + $result = db_query('SELECT cid, category, selected FROM {contact} ORDER BY weight, category'); + while ($category = db_fetch_object($result)) { + $categories[$category->cid] = $category->category; + if ($category->selected) { + $default_category = $category->cid; + } + } + + if (count($categories) > 0) { + $form['#token'] = $user->name . $user->mail; + $form['contact_information'] = array('#value' => filter_xss_admin(variable_get('contact_form_information', t('You can leave us a message using the contact form below.')))); + $form['name'] = array('#type' => 'textfield', + '#title' => t('Your name'), + '#maxlength' => 255, + '#default_value' => $user->uid ? $user->name : '', + '#required' => TRUE, + ); + $form['mail'] = array('#type' => 'textfield', + '#title' => t('Your e-mail address'), + '#maxlength' => 255, + '#default_value' => $user->uid ? $user->mail : '', + '#required' => TRUE, + ); + $form['subject'] = array('#type' => 'textfield', + '#title' => t('Subject'), + '#maxlength' => 255, + '#required' => TRUE, + ); + if (count($categories) > 1) { + // If there is more than one category available and no default category has been selected, + // prepend a default placeholder value. + if (!isset($default_category)) { + $categories = array(t('--')) + $categories; } - $form['message'] = array('#type' => 'textarea', - '#title' => t('Message'), + $form['cid'] = array('#type' => 'select', + '#title' => t('Category'), + '#default_value' => $default_category, + '#options' => $categories, '#required' => TRUE, ); - $form['copy'] = array('#type' => 'checkbox', - '#title' => t('Send me a copy.'), - ); - $form['submit'] = array('#type' => 'submit', - '#value' => t('Send e-mail'), - ); - $output = drupal_get_form('contact_mail_page', $form); } else { - $output = t('The contact form has not been configured.'); + // If there is only one category, store its cid. + $category_keys = array_keys($categories); + $form['cid'] = array('#type' => 'value', + '#value' => array_shift($category_keys), + ); } + $form['message'] = array('#type' => 'textarea', + '#title' => t('Message'), + '#required' => TRUE, + ); + $form['copy'] = array('#type' => 'checkbox', + '#title' => t('Send me a copy.'), + ); + $form['submit'] = array('#type' => 'submit', + '#value' => t('Send e-mail'), + ); } - - return $output; + else { + $form['#error'] = array('#value' => t('The contact form has not been configured.')); + } + $form['#form_id'] = 'contact_mail_page'; + return $form; } /** === modified file 'modules/filter/filter.module' --- modules/filter/filter.module +++ modules/filter/filter.module @@ -316,7 +316,7 @@ function filter_admin_overview() { } $form['default'] = array('#type' => 'radios', '#options' => $options, '#default_value' => variable_get('filter_default_format', 1)); $form['submit'] = array('#type' => 'submit', '#value' => t('Set default format')); - return drupal_get_form('filter_admin_overview', $form); + return $form; } function filter_admin_overview_submit($form_id, $form_values) { @@ -440,8 +440,6 @@ function filter_admin_format_form($forma '#description' => module_invoke($filter->module, 'filter', 'description', $filter->delta), ); } - $form['submit'] = array('#type' => 'submit', '#value' => t('Save configuration')); - if (isset($format)) { $form['format'] = array('#type' => 'hidden', '#value' => $format->format); @@ -454,11 +452,11 @@ function filter_admin_format_form($forma } $group = t('

These are the guidelines that users will see for posting in this input format. They are automatically generated from the filter settings.

'); $group .= $tiplist; - $output = '

'. t('Formatting guidelines') .'

'. $group; + $form['tips'] = array('#value' => '

'. t('Formatting guidelines') .'

'. $group); } - $output = drupal_get_form('filter_admin_format_form', $form) . $output; + $form['submit'] = array('#type' => 'submit', '#value' => t('Save configuration')); - return $output; + return $form; } /** @@ -549,7 +547,7 @@ function filter_admin_order($format = NU $form['format'] = array('#type' => 'hidden', '#value' => $format->format); $form['submit'] = array('#type' => 'submit', '#value' => t('Save configuration')); - return drupal_get_form('filter_admin_order', $form); + return $form; } /** === modified file 'modules/forum/forum.module' --- modules/forum/forum.module +++ modules/forum/forum.module @@ -476,8 +476,9 @@ function forum_form_container($edit = ar $form['delete'] = array('#type' => 'submit', '#value' => t('Delete')); $form['tid'] = array('#type' => 'value', '#value' => $edit['tid']); } + $form['#function_prefix'] = 'forum_form'; - return drupal_get_form('forum_form_container', $form, 'forum_form'); + return $form; } /** @@ -517,8 +518,9 @@ function forum_form_forum($edit = array( $form['delete'] = array('#type' => 'submit', '#value' => t('Delete')); $form['tid'] = array('#type' => 'hidden', '#value' => $edit['tid']); } + $form['#function_prefix'] = 'forum_form'; - return drupal_get_form('forum_form_forum', $form, 'forum_form'); + return $form; } /** === modified file 'modules/menu/menu.module' --- modules/menu/menu.module +++ modules/menu/menu.module @@ -331,9 +331,10 @@ function menu_edit_menu_form($type, $mid $form['weight'] = array('#type' => 'value', '#value' => $item['weight']); $form['type'] = array('#type' => 'value', '#value' => $item['type']); $form['submit'] = array('#type' => 'submit', '#value' => t('Submit')); - // Reuse the submit function of menu_edit_item_form. - return drupal_get_form('menu_edit_menu_form', $form, 'menu_edit_item_form'); + $form['#function_prefix'] = 'menu_edit_item_form'; + + return $form; } /** @@ -411,7 +412,7 @@ function menu_edit_item_form($type, $mid $form['mid'] = array('#type' => 'value', '#value' => $item['mid']); $form['submit'] = array('#type' => 'submit', '#value' => t('Submit')); - return drupal_get_form('menu_edit_item_form', $form); + return $form; } /** === modified file 'modules/node/node.module' --- modules/node/node.module +++ modules/node/node.module @@ -1288,13 +1288,13 @@ function node_filter_form() { $form['filters']['buttons']['reset'] = array('#type' => 'submit', '#value' => t('Reset')); } - return drupal_get_form('node_filter_form', $form); + return $form; } /** * Theme node administration filter form. */ -function theme_node_filter_form(&$form) { +function theme_node_filter_form($form) { $output .= '
'; $output .= drupal_render($form['filters']); $output .= '
'; @@ -1305,7 +1305,7 @@ function theme_node_filter_form(&$form) /** * Theme node administraton filter selector. */ -function theme_node_filters(&$form) { +function theme_node_filters($form) { $output .= '