diff options
Diffstat (limited to 'includes')
-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 |
4 files changed, 24 insertions, 55 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(); |