diff options
-rw-r--r-- | includes/common.inc | 4 | ||||
-rw-r--r-- | includes/form.inc | 61 | ||||
-rw-r--r-- | includes/locale.inc | 12 | ||||
-rw-r--r-- | includes/theme.inc | 2 | ||||
-rw-r--r-- | install.php | 9 | ||||
-rw-r--r-- | modules/comment/comment.admin.inc | 4 | ||||
-rw-r--r-- | modules/comment/comment.module | 2 | ||||
-rw-r--r-- | modules/dblog/dblog.admin.inc | 4 | ||||
-rw-r--r-- | modules/openid/openid.inc | 2 | ||||
-rw-r--r-- | modules/openid/openid.pages.inc | 2 | ||||
-rw-r--r-- | modules/poll/poll.module | 8 | ||||
-rw-r--r-- | modules/search/search.module | 2 | ||||
-rw-r--r-- | modules/search/search.pages.inc | 2 | ||||
-rw-r--r-- | modules/simpletest/tests/form_test.module | 12 | ||||
-rw-r--r-- | modules/system/system.admin.inc | 6 | ||||
-rw-r--r-- | modules/system/system.module | 2 | ||||
-rw-r--r-- | modules/taxonomy/taxonomy.admin.inc | 1 | ||||
-rw-r--r-- | modules/trigger/trigger.admin.inc | 6 | ||||
-rw-r--r-- | modules/user/user.admin.inc | 10 | ||||
-rw-r--r-- | modules/user/user.module | 4 | ||||
-rw-r--r-- | update.php | 2 |
21 files changed, 62 insertions, 95 deletions
diff --git a/includes/common.inc b/includes/common.inc index 46d320d54..ea7b02a74 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -3252,8 +3252,8 @@ function drupal_get_page($content = NULL) { * @see drupal_get_page() */ function drupal_render_page($page) { - // Allow menu callbacks to return strings. - if (is_string($page)) { + // Allow menu callbacks to return strings, or bare content arrays. + if (is_string($page) || empty($page['content'])) { $page = drupal_get_page($page); } // Modules alter the $page as needed. Blocks are populated into regions like diff --git a/includes/form.inc b/includes/form.inc index 4dd5b9445..10c344712 100644 --- a/includes/form.inc +++ b/includes/form.inc @@ -29,8 +29,8 @@ * presentation, while simplifying code and reducing the amount of HTML that * must be explicitly generated by modules. * - * The drupal_get_form() function handles retrieving, processing, and - * displaying a rendered HTML form for modules automatically. For example: + * The drupal_get_form() function handles retrieving and processing an HTML + * form for modules automatically. For example: * * @code * // Display the user registration form. @@ -62,7 +62,7 @@ * example, the node_edit form requires that a node object is passed in here * when it is called. * @return - * The rendered form. + * The form array. * * @see drupal_build_form() */ @@ -78,12 +78,11 @@ function drupal_get_form($form_id) { } /** - * Build, render, and process a form based on a form id. + * Build and process a form based on a form id. * * The form may also be retrieved from the cache if the form was built in a * previous page-load. The form is then passed on for processing, validation - * and submission if there is proper input, and then rendered for display - * if necessary. + * and submission if there is proper input. * * @param $form_id * The unique string identifying the desired form. If a function with that @@ -107,13 +106,6 @@ function drupal_get_form($form_id) { * forms do not use form ids so are always considered to be submitted, which * can have unexpected effects. The 'get' method should only be used on * forms that do not change data, as that is exclusively the domain of post. - * - rerender: May be set to FALSE to force the form to not be re-rendered - * after submit. Ordinarily, forms are re-rendered after a successful submit - * if there is no redirect. However, many forms may want to perform some - * other action, but not necessarily re-render the form. This is - * particularly true when using AHAH or AJAX where some data may be returned - * to the calling JavaScript. Note that a form validation error will always - * re-render the form. * - no_redirect: If set to TRUE the form will NOT perform a drupal_goto(), * even if a redirect is set. * - always_process: If TRUE and the method is GET, a form_id is not @@ -181,10 +173,6 @@ function drupal_build_form($form_id, &$form_state) { // altering the $form_state variable, which is passed into them by // reference. drupal_process_form($form_id, $form, $form_state); - // If we were told not to redirect, but not told to re-render, return here. - if (!empty($form_state['executed']) && empty($form_state['rerender'])) { - return; - } if ($cacheable && !empty($form['#cache']) && empty($form['#no_cache'])) { // Caching is done past drupal_process_form so #process callbacks can @@ -210,10 +198,17 @@ function drupal_build_form($form_id, &$form_state) { if ((!empty($form_state['storage']) || !empty($form_state['rebuild'])) && !empty($form_state['submitted']) && !form_get_errors()) { $form = drupal_rebuild_form($form_id, $form_state); } + + // Don't override #theme if someone already set it. + if (!isset($form['#theme'])) { + init_theme(); + $registry = theme_get_registry(); + if (isset($registry[$form_id])) { + $form['#theme'] = $form_id; + } + } - // If we haven't redirected to a new location by now, we want to - // render whatever form array is currently in hand. - return drupal_render_form($form_id, $form); + return $form; } /** @@ -224,7 +219,6 @@ function form_state_defaults() { 'storage' => NULL, 'submitted' => FALSE, 'method' => 'post', - 'rerender' => TRUE, 'programmed' => FALSE, 'groups' => array(), ); @@ -679,31 +673,6 @@ function drupal_validate_form($form_id, $form, &$form_state) { } /** - * Renders a structured form array into themed HTML. - * - * @param $form_id - * A unique string identifying the form for validation, submission, - * theming, and hook_form_alter functions. - * @param $form - * An associative array containing the structure of the form. - * @return - * A string containing the themed HTML. - */ -function drupal_render_form($form_id, &$form) { - // Don't override #theme if someone already set it. - if (!isset($form['#theme'])) { - init_theme(); - $registry = theme_get_registry(); - if (isset($registry[$form_id])) { - $form['#theme'] = $form_id; - } - } - - $output = drupal_render($form); - return $output; -} - -/** * Redirect the user to a URL after a form has been processed. * * @param $form diff --git a/includes/locale.inc b/includes/locale.inc index e7a3534a0..d94e09f24 100644 --- a/includes/locale.inc +++ b/includes/locale.inc @@ -158,9 +158,9 @@ function locale_languages_overview_form_submit($form, &$form_state) { * User interface for the language addition screen. */ function locale_languages_add_screen() { - $output = drupal_get_form('locale_languages_predefined_form'); - $output .= drupal_get_form('locale_languages_custom_form'); - return $output; + $build['predefined'] = drupal_get_form('locale_languages_predefined_form'); + $build['custom'] = drupal_get_form('locale_languages_custom_form'); + return $build; } /** @@ -564,7 +564,7 @@ function locale_translate_seek_screen() { // Add CSS. drupal_add_css(drupal_get_path('module', 'locale') . '/locale.css', array('preprocess' => FALSE)); - $output = drupal_get_form('locale_translation_filter_form'); + $output = drupal_render(drupal_get_form('locale_translation_filter_form')); $output .= _locale_translate_seek(); return $output; } @@ -807,9 +807,9 @@ function locale_translate_export_screen() { $output = ''; // Offer translation export if any language is set up. if (count($names)) { - $output = drupal_get_form('locale_translate_export_po_form', $names); + $output = drupal_render(drupal_get_form('locale_translate_export_po_form', $names)); } - $output .= drupal_get_form('locale_translate_export_pot_form'); + $output .= drupal_render(drupal_get_form('locale_translate_export_pot_form')); return $output; } diff --git a/includes/theme.inc b/includes/theme.inc index 84b823b78..c6c0fd333 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -1824,7 +1824,7 @@ function template_preprocess_page(&$variables) { $variables['messages'] = $variables['show_messages'] ? theme('status_messages') : ''; $variables['main_menu'] = theme_get_setting('toggle_main_menu') ? menu_main_menu() : array(); $variables['secondary_menu'] = theme_get_setting('toggle_secondary_menu') ? menu_secondary_menu() : array(); - $variables['search_box'] = (theme_get_setting('toggle_search') ? drupal_get_form('search_theme_form') : ''); + $variables['search_box'] = (theme_get_setting('toggle_search') ? drupal_render(drupal_get_form('search_theme_form')) : ''); $variables['site_name'] = (theme_get_setting('toggle_name') ? variable_get('site_name', 'Drupal') : ''); $variables['site_slogan'] = (theme_get_setting('toggle_slogan') ? variable_get('site_slogan', '') : ''); $variables['css'] = drupal_add_css(); diff --git a/install.php b/install.php index 67e65084d..194c5abb3 100644 --- a/install.php +++ b/install.php @@ -212,7 +212,7 @@ function install_change_settings($profile = 'default', $install_locale = '') { include_once DRUPAL_ROOT . '/includes/form.inc'; install_task_list('database'); - $output = drupal_get_form('install_settings_form', $profile, $install_locale, $settings_file, $database); + $output = drupal_render(drupal_get_form('install_settings_form', $profile, $install_locale, $settings_file, $database)); drupal_set_title(st('Database configuration')); print theme('install_page', $output); exit; @@ -433,7 +433,7 @@ function install_select_profile() { install_task_list('profile-select'); drupal_set_title(st('Select an installation profile')); - print theme('install_page', drupal_get_form('install_select_profile_form', $profiles)); + print theme('install_page', drupal_render(drupal_get_form('install_select_profile_form', $profiles))); exit; } } @@ -560,7 +560,8 @@ function install_select_locale($profilename) { install_task_list('locale-select'); drupal_set_title(st('Choose language')); - print theme('install_page', drupal_get_form('install_select_locale_form', $locales)); + + print theme('install_page', drupal_render(drupal_get_form('install_select_locale_form', $locales))); exit; } } @@ -703,7 +704,7 @@ function install_tasks($profile, $task) { // got accidentally blown somewhere. Stop it now. install_already_done_error(); } - $form = drupal_get_form('install_configure_form', $url); + $form = drupal_render(drupal_get_form('install_configure_form', $url)); if (!variable_get('site_name', FALSE) && !variable_get('site_mail', FALSE)) { // Not submitted yet: Prepare to display the form. diff --git a/modules/comment/comment.admin.inc b/modules/comment/comment.admin.inc index 15c426390..156149754 100644 --- a/modules/comment/comment.admin.inc +++ b/modules/comment/comment.admin.inc @@ -13,10 +13,10 @@ function comment_admin($type = 'new') { $edit = $_POST; if (isset($edit['operation']) && ($edit['operation'] == 'delete') && isset($edit['comments']) && $edit['comments']) { - return drupal_get_form('comment_multiple_delete_confirm'); + return drupal_render(drupal_get_form('comment_multiple_delete_confirm')); } else { - return drupal_get_form('comment_admin_overview', $type, arg(4)); + return drupal_render(drupal_get_form('comment_admin_overview', $type, arg(4))); } } diff --git a/modules/comment/comment.module b/modules/comment/comment.module index 0a59cde46..a471b65f1 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -1626,7 +1626,7 @@ function comment_form(&$form_state, $edit, $title = NULL) { * A string containing the box output. */ function theme_comment_form_box($edit, $title = NULL) { - $content = drupal_get_form('comment_form', $edit, $title); + $content = drupal_render(drupal_get_form('comment_form', $edit, $title)); $output = '<h2 class="title">' . $title . '</h2><div>' . $content . '</div>'; return $output; } diff --git a/modules/dblog/dblog.admin.inc b/modules/dblog/dblog.admin.inc index c5a27f86d..9324ac621 100644 --- a/modules/dblog/dblog.admin.inc +++ b/modules/dblog/dblog.admin.inc @@ -47,8 +47,8 @@ function dblog_overview() { WATCHDOG_EMERG => 'dblog-emerg', ); - $output = drupal_get_form('dblog_filter_form'); - $output .= drupal_get_form('dblog_clear_log_form'); + $output = drupal_render(drupal_get_form('dblog_filter_form')); + $output .= drupal_render(drupal_get_form('dblog_clear_log_form')); $header = array( ' ', diff --git a/modules/openid/openid.inc b/modules/openid/openid.inc index c0ed8a936..7df2262d6 100644 --- a/modules/openid/openid.inc +++ b/modules/openid/openid.inc @@ -69,7 +69,7 @@ function openid_redirect_http($url, $message) { */ function openid_redirect($url, $message) { $output = '<html><head><title>' . t('OpenID redirect') . "</title></head>\n<body>"; - $output .= drupal_get_form('openid_redirect_form', $url, $message); + $output .= drupal_render(drupal_get_form('openid_redirect_form', $url, $message)); $output .= '<script type="text/javascript">document.getElementById("openid-redirect-form").submit();</script>'; $output .= "</body></html>\n"; print $output; diff --git a/modules/openid/openid.pages.inc b/modules/openid/openid.pages.inc index 2f361a9b6..94c2a441f 100644 --- a/modules/openid/openid.pages.inc +++ b/modules/openid/openid.pages.inc @@ -54,7 +54,7 @@ function openid_user_identities($account) { } $output = theme('table', $header, $rows); - $output .= drupal_get_form('openid_user_add'); + $output .= drupal_render(drupal_get_form('openid_user_add')); return $output; } diff --git a/modules/poll/poll.module b/modules/poll/poll.module index 02b6a81c7..1c33e5ee9 100644 --- a/modules/poll/poll.module +++ b/modules/poll/poll.module @@ -567,14 +567,10 @@ function poll_view($node, $teaser = FALSE, $block = FALSE) { } if (!empty($node->allowvotes) && ($block || empty($node->show_results))) { - $node->content['body'] = array( - '#markup' => drupal_get_form('poll_view_voting', $node, $block), - ); + $node->content['poll_view_voting'] = drupal_get_form('poll_view_voting', $node, $block); } else { - $node->content['body'] = array( - '#markup' => poll_view_results($node, $teaser, $block), - ); + $node->content['poll_view_results'] = array('#markup' => poll_view_results($node, $teaser, $block)); } return $node; } diff --git a/modules/search/search.module b/modules/search/search.module index cd57dfd24..6ce7bd21b 100644 --- a/modules/search/search.module +++ b/modules/search/search.module @@ -175,7 +175,7 @@ function search_block_list() { */ function search_block_view($delta = '') { if (user_access('search content')) { - $block['content'] = drupal_get_form('search_block_form'); + $block['content'] = drupal_render(drupal_get_form('search_block_form')); $block['subject'] = t('Search'); return $block; } diff --git a/modules/search/search.pages.inc b/modules/search/search.pages.inc index f431994d8..a8d7ce8fb 100644 --- a/modules/search/search.pages.inc +++ b/modules/search/search.pages.inc @@ -40,7 +40,7 @@ function search_view($type = 'node') { } // Construct the search form. - $output = drupal_get_form('search_form', NULL, $keys, $type); + $output = drupal_render(drupal_get_form('search_form', NULL, $keys, $type)); $output .= $results; return $output; diff --git a/modules/simpletest/tests/form_test.module b/modules/simpletest/tests/form_test.module index 547de062e..f9053c57e 100644 --- a/modules/simpletest/tests/form_test.module +++ b/modules/simpletest/tests/form_test.module @@ -70,13 +70,13 @@ function form_test_menu() { } /** - * Generate a page with three form, to test the clean_id generation. + * Generate a page with three forms, to test the clean_id generation. */ function form_test_form_clean_id_page() { - $output = drupal_get_form('form_test_test_form'); - $output .= drupal_get_form('form_test_test_form'); - $output .= drupal_get_form('form_test_test_form'); - return $output; + $build['form_test_test_form1'] = drupal_get_form('form_test_test_form'); + $build['form_test_test_form2'] = drupal_get_form('form_test_test_form'); + $build['form_test_test_form3'] = drupal_get_form('form_test_test_form'); + return $build; } /** @@ -335,7 +335,7 @@ function form_storage_test_form(&$form_state) { ); } else { - $form['content'] = array('#value' => 'This is the second step.'); + $form['body'] = array('#value' => 'This is the second step.'); $form['submit'] = array( '#type' => 'submit', '#value' => 'Save', diff --git a/modules/system/system.admin.inc b/modules/system/system.admin.inc index bc3dea60a..d3a607ce3 100644 --- a/modules/system/system.admin.inc +++ b/modules/system/system.admin.inc @@ -1084,11 +1084,11 @@ function system_ip_blocking() { ); } - $output .= drupal_get_form('system_ip_blocking_form'); + $build['system_ip_blocking_form'] = drupal_get_form('system_ip_blocking_form'); - $output .= theme('table', $header, $rows); + $build['system_ip_blocking_table'] = array('#markup' => theme('table', $header, $rows)); - return $output; + return $build; } /** diff --git a/modules/system/system.module b/modules/system/system.module index 51ce7e288..57f0b787e 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -1709,7 +1709,7 @@ function system_actions_manage() { } if ($actions_map) { - $output .= drupal_get_form('system_actions_manage_form', $options); + $output .= drupal_render(drupal_get_form('system_actions_manage_form', $options)); } return $output; diff --git a/modules/taxonomy/taxonomy.admin.inc b/modules/taxonomy/taxonomy.admin.inc index 5c5c4adb7..b71db8301 100644 --- a/modules/taxonomy/taxonomy.admin.inc +++ b/modules/taxonomy/taxonomy.admin.inc @@ -64,6 +64,7 @@ function taxonomy_overview_vocabularies_submit($form, &$form_state) { */ function theme_taxonomy_overview_vocabularies($form) { $rows = array(); + foreach (element_children($form) as $key) { if (isset($form[$key]['name'])) { $vocabulary = &$form[$key]; diff --git a/modules/trigger/trigger.admin.inc b/modules/trigger/trigger.admin.inc index 7d6c2621e..02f9cff9d 100644 --- a/modules/trigger/trigger.admin.inc +++ b/modules/trigger/trigger.admin.inc @@ -21,17 +21,17 @@ function trigger_assign($type = NULL) { drupal_goto('admin/build/trigger/node'); } - $output = ''; + $build = array(); $hooks = module_invoke_all('hook_info'); foreach ($hooks as $module => $hook) { if (isset($hook[$type])) { foreach ($hook[$type] as $op => $description) { $form_id = 'trigger_' . $type . '_' . $op . '_assign_form'; - $output .= drupal_get_form($form_id, $type, $op, $description['runs when']); + $build[$form_id] = drupal_get_form($form_id, $type, $op, $description['runs when']); } } } - return $output; + return $build; } /** diff --git a/modules/user/user.admin.inc b/modules/user/user.admin.inc index 1f9913746..0435f9621 100644 --- a/modules/user/user.admin.inc +++ b/modules/user/user.admin.inc @@ -12,18 +12,18 @@ function user_admin($callback_arg = '') { switch ($op) { case t('Create new account'): case 'create': - $output = drupal_get_form('user_register'); + $build['user_register'] = drupal_get_form('user_register'); break; default: if (!empty($_POST['accounts']) && isset($_POST['operation']) && ($_POST['operation'] == 'cancel')) { - $output = drupal_get_form('user_multiple_cancel_confirm'); + $build['user_multiple_cancel_confirm'] = drupal_get_form('user_multiple_cancel_confirm'); } else { - $output = drupal_get_form('user_filter_form'); - $output .= drupal_get_form('user_admin_account'); + $build['user_filter_form'] = drupal_get_form('user_filter_form'); + $build['user_admin_account'] = drupal_get_form('user_admin_account'); } } - return $output; + return $build; } /** diff --git a/modules/user/user.module b/modules/user/user.module index 29b43cb36..0611c53e6 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -138,7 +138,7 @@ function user_external_load($authname) { * TRUE if the login succeeds, FALSE otherwise. */ function user_external_login($account, $edit = array()) { - $form = drupal_get_form('user_login'); + $form = drupal_render(drupal_get_form('user_login')); $state['values'] = $edit; if (empty($state['values']['name'])) { @@ -1099,7 +1099,7 @@ function user_block_view($delta = '') { if (!$user->uid && !(arg(0) == 'user' && !is_numeric(arg(1)))) { $block['subject'] = t('User login'); - $block['content'] = drupal_get_form('user_login_block'); + $block['content'] = drupal_render(drupal_get_form('user_login_block')); } return $block; diff --git a/update.php b/update.php index 69cf108ac..907a84c56 100644 --- a/update.php +++ b/update.php @@ -195,7 +195,7 @@ function update_do_one($module, $number, &$context) { function update_selection_page() { drupal_set_title('Drupal database update'); - $output = drupal_get_form('update_script_selection_form'); + $output = drupal_render(drupal_get_form('update_script_selection_form')); update_task_list('select'); |