diff --git a/includes/form.inc b/includes/form.inc index 83e37c38570..5ebd18b7cd3 100644 --- a/includes/form.inc +++ b/includes/form.inc @@ -95,7 +95,6 @@ function drupal_get_form($form_id) { * An array which stores information about the form. This is passed as a * reference so that the caller can use it to examine what the form changed * when the form submission process is complete. - * * The following parameters may be set in $form_state to affect how the form * is rendered: * - args: An array of arguments to pass to the form builder. @@ -117,6 +116,12 @@ function drupal_get_form($form_id) { * times when a form is resubmitted internally and should be validated * again. Setting this to TRUE will force that to happen. This is most * likely to occur during AHAH or AJAX operations. + * - wrapper_callback: Modules that wish to pre-populate certain forms with + * common elements, such as back/next/save buttons in multi-step form + * wizards, may define a form builder function name that returns a form + * structure, which is passed on to the actual form builder function. + * Such forms cannot use drupal_get_form() and need to prepare $form_state + * on their own. * @return * The rendered form or NULL, depending upon the $form_state flags that were set. */ @@ -464,10 +469,21 @@ function drupal_retrieve_form($form_id, &$form_state) { } } - // We need to pass $form_state by reference in order for forms to modify it, - // since call_user_func_array() requires that referenced variables be passed - // explicitly. - $args = array_merge(array(&$form_state), $args); + // When the passed $form_state (not using drupal_get_form()) defines a + // 'wrapper_callback', then it requests to invoke a separate (wrapping) form + // builder function to pre-populate the $form array with form elements, which + // the actual form builder function ($callback) expects. This allows for + // pre-populating a form with common elements for certain forms, such as + // back/next/save buttons in multi-step form wizards. + // @see drupal_build_form() + $form = array(); + if (isset($form_state['wrapper_callback']) && function_exists($form_state['wrapper_callback'])) { + $form = $form_state['wrapper_callback']($form, $form_state); + } + // We need to pass $form_state by reference in order for forms to modify it, + // since call_user_func_array() requires that referenced variables be passed + // explicitly. + $args = array_merge(array($form, &$form_state), $args); // If $callback was returned by a hook_forms() implementation, call it. // Otherwise, call the function named after the form id. diff --git a/includes/locale.inc b/includes/locale.inc index 8e803eb612b..4962f2fd76d 100644 --- a/includes/locale.inc +++ b/includes/locale.inc @@ -166,9 +166,8 @@ function locale_languages_add_screen() { /** * Predefined language setup form. */ -function locale_languages_predefined_form() { +function locale_languages_predefined_form($form) { $predefined = _locale_prepare_predefined_list(); - $form = array(); $form['language list'] = array('#type' => 'fieldset', '#title' => t('Predefined language'), '#collapsible' => TRUE, @@ -186,8 +185,7 @@ function locale_languages_predefined_form() { /** * Custom language addition form. */ -function locale_languages_custom_form() { - $form = array(); +function locale_languages_custom_form($form) { $form['custom language'] = array('#type' => 'fieldset', '#title' => t('Custom language'), '#collapsible' => TRUE, @@ -210,9 +208,8 @@ function locale_languages_custom_form() { * @param $langcode * Language code of the language to edit. */ -function locale_languages_edit_form(&$form_state, $langcode) { +function locale_languages_edit_form($form, &$form_state, $langcode) { if ($language = db_query("SELECT * FROM {languages} WHERE language = :language", array(':language' => $langcode))->fetchObject()) { - $form = array(); _locale_languages_common_controls($form, $language); $form['submit'] = array( '#type' => 'submit', @@ -406,7 +403,7 @@ function locale_languages_edit_form_submit($form, &$form_state) { /** * User interface for the language deletion confirmation screen. */ -function locale_languages_delete_form(&$form_state, $langcode) { +function locale_languages_delete_form($form, &$form_state, $langcode) { // Do not allow deletion of English locale. if ($langcode == 'en') { @@ -698,7 +695,7 @@ function locale_translation_filter_form_submit($form, &$form_state) { /** * User interface for the translation import screen. */ -function locale_translate_import_form() { +function locale_translate_import_form($form) { // Get all languages, except English drupal_static_reset('language_list'); $names = locale_language_list('name'); @@ -716,7 +713,6 @@ function locale_translate_import_form() { $default = key($names); } - $form = array(); $form['import'] = array('#type' => 'fieldset', '#title' => t('Import translation'), ); @@ -816,7 +812,7 @@ function locale_translate_export_screen() { * @param $names * An associate array with localized language names */ -function locale_translate_export_po_form(&$form_state, $names) { +function locale_translate_export_po_form($form, &$form_state, $names) { $form['export'] = array('#type' => 'fieldset', '#title' => t('Export translation'), '#collapsible' => TRUE, @@ -881,7 +877,7 @@ function locale_translate_export_po_form_submit($form, &$form_state) { /** * User interface for string editing. */ -function locale_translate_edit_form(&$form_state, $lid) { +function locale_translate_edit_form($form, &$form_state, $lid) { // Fetch source string, if possible. $source = db_query('SELECT source, context, textgroup, location FROM {locales_source} WHERE lid = :lid', array(':lid' => $lid))->fetchObject(); if (!$source) { @@ -1051,7 +1047,7 @@ function locale_translate_delete_page($lid) { /** * User interface for the string deletion confirmation screen. */ -function locale_translate_delete_form(&$form_state, $source) { +function locale_translate_delete_form($form, &$form_state, $source) { $form['lid'] = array('#type' => 'value', '#value' => $source->lid); return confirm_form($form, t('Are you sure you want to delete the string "%source"?', array('%source' => $source->source)), 'admin/config/regional/translate/translate', t('Deleting the string will remove all translations of this string in all languages. This action cannot be undone.'), t('Delete'), t('Cancel')); } diff --git a/install.php b/install.php index 8b3e52ebe3d..b9f19f7a54b 100644 --- a/install.php +++ b/install.php @@ -801,7 +801,7 @@ function install_verify_settings() { * @return * The form API definition for the database configuration form. */ -function install_settings_form(&$form_state, &$install_state) { +function install_settings_form($form, &$form_state, &$install_state) { global $databases, $db_prefix; $profile = $install_state['parameters']['profile']; $install_locale = $install_state['parameters']['locale']; @@ -1069,7 +1069,7 @@ function _install_select_profile($profiles) { * @param $profile_files * Array of .profile files, as returned from file_scan_directory(). */ -function install_select_profile_form(&$form_state, $profile_files) { +function install_select_profile_form($form, &$form_state, $profile_files) { $profiles = array(); $names = array(); @@ -1205,7 +1205,7 @@ function install_select_locale(&$install_state) { /** * Form API array definition for language selection. */ -function install_select_locale_form(&$form_state, $locales) { +function install_select_locale_form($form, &$form_state, $locales) { include_once DRUPAL_ROOT . '/includes/iso.inc'; $languages = _locale_get_predefined_list(); foreach ($locales as $locale) { @@ -1337,7 +1337,7 @@ function install_import_locales(&$install_state) { * @return * The form API definition for the site configuration form. */ -function install_configure_form(&$form_state, &$install_state) { +function install_configure_form($form, &$form_state, &$install_state) { if (variable_get('site_name', FALSE) || variable_get('site_mail', FALSE)) { // Site already configured: This should never happen, means re-running the // installer, possibly by an attacker after the 'install_task' variable got @@ -1382,7 +1382,7 @@ function install_configure_form(&$form_state, &$install_state) { drupal_get_schema(NULL, TRUE); // Return the form. - return _install_configure_form($form_state, $install_state); + return _install_configure_form($form, $form_state, $install_state); } /** @@ -1535,7 +1535,7 @@ function install_check_requirements($install_state) { /** * Form API array definition for site configuration. */ -function _install_configure_form(&$form_state, &$install_state) { +function _install_configure_form($form, &$form_state, &$install_state) { include_once DRUPAL_ROOT . '/includes/locale.inc'; $form['site_information'] = array( diff --git a/modules/aggregator/aggregator.admin.inc b/modules/aggregator/aggregator.admin.inc index 05efbe1510b..b1fc85a8dfc 100644 --- a/modules/aggregator/aggregator.admin.inc +++ b/modules/aggregator/aggregator.admin.inc @@ -58,7 +58,7 @@ function aggregator_view() { * @see aggregator_form_feed_validate() * @see aggregator_form_feed_submit() */ -function aggregator_form_feed(&$form_state, stdClass $feed = NULL) { +function aggregator_form_feed($form, &$form_state, stdClass $feed = NULL) { $period = drupal_map_assoc(array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200), 'format_interval'); $period[AGGREGATOR_CLEAR_NEVER] = t('Never'); @@ -196,7 +196,7 @@ function aggregator_form_feed_submit($form, &$form_state) { } } -function aggregator_admin_remove_feed($form_state, $feed) { +function aggregator_admin_remove_feed($form, $form_state, $feed) { return confirm_form( array( 'feed' => array( @@ -230,7 +230,7 @@ function aggregator_admin_remove_feed_submit($form, &$form_state) { * @see aggregator_form_opml_validate() * @see aggregator_form_opml_submit() */ -function aggregator_form_opml(&$form_state) { +function aggregator_form_opml($form, &$form_state) { $period = drupal_map_assoc(array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200), 'format_interval'); $form['upload'] = array( @@ -390,7 +390,7 @@ function aggregator_admin_refresh_feed($feed) { * * @ingroup forms */ -function aggregator_admin_form($form_state) { +function aggregator_admin_form($form, $form_state) { // Make sure configuration is sane. aggregator_sanitize_configuration(); @@ -496,7 +496,7 @@ function aggregator_admin_form_submit($form, &$form_state) { * @see aggregator_form_category_validate() * @see aggregator_form_category_submit() */ -function aggregator_form_category(&$form_state, $edit = array('title' => '', 'description' => '', 'cid' => NULL)) { +function aggregator_form_category($form, &$form_state, $edit = array('title' => '', 'description' => '', 'cid' => NULL)) { $form['title'] = array('#type' => 'textfield', '#title' => t('Title'), '#default_value' => $edit['title'], diff --git a/modules/aggregator/aggregator.test b/modules/aggregator/aggregator.test index b8ea4120f95..16d5e64ca26 100644 --- a/modules/aggregator/aggregator.test +++ b/modules/aggregator/aggregator.test @@ -551,20 +551,20 @@ class ImportOPMLTestCase extends AggregatorTestCase { function validateImportFormFields() { $before = db_query('SELECT COUNT(*) FROM {aggregator_feed}')->fetchField(); - $form = array(); - $this->drupalPost('admin/config/services/aggregator/add/opml', $form, t('Import')); + $edit = array(); + $this->drupalPost('admin/config/services/aggregator/add/opml', $edit, t('Import')); $this->assertRaw(t('You must either upload a file or enter a URL.'), t('Error if no fields are filled.')); $path = $this->getEmptyOpml(); - $form = array( + $edit = array( 'files[upload]' => $path, 'remote' => file_create_url($path), ); - $this->drupalPost('admin/config/services/aggregator/add/opml', $form, t('Import')); + $this->drupalPost('admin/config/services/aggregator/add/opml', $edit, t('Import')); $this->assertRaw(t('You must either upload a file or enter a URL.'), t('Error if both fields are filled.')); - $form = array('remote' => 'invalidUrl://empty'); - $this->drupalPost('admin/config/services/aggregator/add/opml', $form, t('Import')); + $edit = array('remote' => 'invalidUrl://empty'); + $this->drupalPost('admin/config/services/aggregator/add/opml', $edit, t('Import')); $this->assertText(t('This URL is not valid.'), t('Error if the URL is invalid.')); $after = db_query('SELECT COUNT(*) FROM {aggregator_feed}')->fetchField(); @@ -581,8 +581,8 @@ class ImportOPMLTestCase extends AggregatorTestCase { $this->drupalPost('admin/config/services/aggregator/add/opml', $form, t('Import')); $this->assertText(t('No new feed has been added.'), t('Attempting to upload invalid XML.')); - $form = array('remote' => file_create_url($this->getEmptyOpml())); - $this->drupalPost('admin/config/services/aggregator/add/opml', $form, t('Import')); + $edit = array('remote' => file_create_url($this->getEmptyOpml())); + $this->drupalPost('admin/config/services/aggregator/add/opml', $edit, t('Import')); $this->assertText(t('No new feed has been added.'), t('Attempting to load empty OPML from remote URL.')); $after = db_query('SELECT COUNT(*) FROM {aggregator_feed}')->fetchField(); @@ -604,12 +604,12 @@ class ImportOPMLTestCase extends AggregatorTestCase { $feeds[0] = $this->getFeedEditArray(); $feeds[1] = $this->getFeedEditArray(); $feeds[2] = $this->getFeedEditArray(); - $form = array( + $edit = array( 'files[upload]' => $this->getValidOpml($feeds), 'refresh' => '900', 'category[1]' => $category, ); - $this->drupalPost('admin/config/services/aggregator/add/opml', $form, t('Import')); + $this->drupalPost('admin/config/services/aggregator/add/opml', $edit, t('Import')); $this->assertRaw(t('A feed with the URL %url already exists.', array('%url' => $feeds[0]['url'])), t('Verifying that a duplicate URL was identified')); $this->assertRaw(t('A feed named %title already exists.', array('%title' => $feeds[1]['title'])), t('Verifying that a duplicate title was identified')); diff --git a/modules/block/block.admin.inc b/modules/block/block.admin.inc index 91465f9eed8..455b48b38b4 100644 --- a/modules/block/block.admin.inc +++ b/modules/block/block.admin.inc @@ -25,7 +25,7 @@ function block_admin_display($theme = NULL) { /** * Generate main blocks administration form. */ -function block_admin_display_form(&$form_state, $blocks, $theme = NULL) { +function block_admin_display_form($form, &$form_state, $blocks, $theme = NULL) { global $theme_key, $custom_theme; drupal_add_css(drupal_get_path('module', 'block') . '/block.css', array('preprocess' => FALSE)); @@ -42,10 +42,8 @@ function block_admin_display_form(&$form_state, $blocks, $theme = NULL) { $weight_delta = round(count($blocks) / 2); // Build the form tree. - $form = array( - '#action' => arg(4) ? url('admin/structure/block/list/' . $theme_key) : url('admin/structure/block'), - '#tree' => TRUE, - ); + $form['#action'] = arg(4) ? url('admin/structure/block/list/' . $theme_key) : url('admin/structure/block'); + $form['#tree'] = TRUE; foreach ($blocks as $i => $block) { $key = $block['module'] . '_' . $block['delta']; @@ -155,7 +153,7 @@ function _block_compare($a, $b) { /** * Menu callback; displays the block configuration form. */ -function block_admin_configure(&$form_state, $module = NULL, $delta = 0) { +function block_admin_configure($form, &$form_state, $module = NULL, $delta = 0) { $form['module'] = array( '#type' => 'value', '#value' => $module, @@ -406,8 +404,8 @@ function block_admin_configure_submit($form, &$form_state) { /** * Menu callback: display the custom block addition form. */ -function block_add_block_form(&$form_state) { - return block_admin_configure($form_state, 'block', NULL); +function block_add_block_form($form, &$form_state) { + return block_admin_configure($form, $form_state, 'block', NULL); } function block_add_block_form_validate($form, &$form_state) { @@ -489,7 +487,7 @@ function block_add_block_form_submit($form, &$form_state) { /** * Menu callback; confirm deletion of custom blocks. */ -function block_custom_block_delete(&$form_state, $bid = 0) { +function block_custom_block_delete($form, &$form_state, $bid = 0) { $custom_block = block_custom_block_get($bid); $form['info'] = array('#type' => 'hidden', '#value' => $custom_block['info'] ? $custom_block['info'] : $custom_block['title']); $form['bid'] = array('#type' => 'hidden', '#value' => $bid); diff --git a/modules/book/book.admin.inc b/modules/book/book.admin.inc index 8af9b195cd1..d1745473a26 100644 --- a/modules/book/book.admin.inc +++ b/modules/book/book.admin.inc @@ -77,9 +77,8 @@ function book_admin_settings_validate($form, &$form_state) { * * @ingroup forms. */ -function book_admin_edit($form_state, $node) { +function book_admin_edit($form, $form_state, $node) { drupal_set_title($node->title); - $form = array(); $form['#node'] = $node; _book_admin_table($node, $form); $form['save'] = array( diff --git a/modules/book/book.pages.inc b/modules/book/book.pages.inc index 3e139cd815a..5909c5b58b7 100644 --- a/modules/book/book.pages.inc +++ b/modules/book/book.pages.inc @@ -102,7 +102,7 @@ function book_outline($node) { * * @ingroup forms */ -function book_outline_form(&$form_state, $node) { +function book_outline_form($form, &$form_state, $node) { if (!isset($node->book)) { // The node is not part of any book yet - set default options. $node->book = _book_link_defaults($node->nid); @@ -186,7 +186,7 @@ function book_outline_form_submit($form, &$form_state) { * * @ingroup forms */ -function book_remove_form(&$form_state, $node) { +function book_remove_form($form, &$form_state, $node) { $form['#node'] = $node; $title = array('%title' => $node->title); diff --git a/modules/color/color.module b/modules/color/color.module index 7f470bb5d68..67d7ba92236 100644 --- a/modules/color/color.module +++ b/modules/color/color.module @@ -31,7 +31,7 @@ function color_theme() { * Implement hook_form_FORM_ID_alter(). */ function color_form_system_theme_settings_alter(&$form, &$form_state) { - if (color_get_info(arg(3)) && function_exists('gd_info')) { + if (isset($form_state['args'][0]) && ($theme = $form_state['args'][0]) && color_get_info($theme) && function_exists('gd_info')) { $form['color'] = array( '#type' => 'fieldset', '#title' => t('Color scheme'), @@ -39,7 +39,7 @@ function color_form_system_theme_settings_alter(&$form, &$form_state) { '#attributes' => array('id' => 'color_scheme_form'), '#theme' => 'color_scheme_form', ); - $form['color'] += color_scheme_form($form_state, arg(3)); + $form['color'] += color_scheme_form($form, $form_state, $theme); $form['#submit'][] = 'color_scheme_form_submit'; } } @@ -139,7 +139,8 @@ function color_get_palette($theme, $default = FALSE) { /** * Form callback. Returns the configuration form. */ -function color_scheme_form(&$form_state, $theme) { +function color_scheme_form($form, &$form_state, $theme) { + $form = array(); $base = drupal_get_path('module', 'color'); $info = color_get_info($theme); @@ -195,7 +196,7 @@ function color_scheme_form(&$form_state, $theme) { '#size' => 8, ); } - $form['theme'] = array('#type' => 'value', '#value' => arg(3)); + $form['theme'] = array('#type' => 'value', '#value' => $theme); $form['info'] = array('#type' => 'value', '#value' => $info); return $form; diff --git a/modules/comment/comment.admin.inc b/modules/comment/comment.admin.inc index fcb1adf7a1a..2cd5966e48f 100644 --- a/modules/comment/comment.admin.inc +++ b/modules/comment/comment.admin.inc @@ -34,7 +34,7 @@ function comment_admin($type = 'new') { * @see comment_admin_overview_submit() * @see theme_comment_admin_overview() */ -function comment_admin_overview($type = 'new', $arg) { +function comment_admin_overview($form, &$form_state, $arg) { // Build an 'Update options' form. $form['options'] = array( '#type' => 'fieldset', @@ -159,7 +159,7 @@ function comment_admin_overview_submit($form, &$form_state) { * @ingroup forms * @see comment_multiple_delete_confirm_submit() */ -function comment_multiple_delete_confirm(&$form_state) { +function comment_multiple_delete_confirm($form, &$form_state) { $edit = $form_state['input']; $form['comments'] = array( @@ -232,8 +232,7 @@ function comment_delete_page($cid = NULL) { * @ingroup forms * @see comment_confirm_delete_submit() */ -function comment_confirm_delete(&$form_state, $comment) { - $form = array(); +function comment_confirm_delete($form, &$form_state, $comment) { $form['#comment'] = $comment; return confirm_form( $form, diff --git a/modules/comment/comment.module b/modules/comment/comment.module index e02f964f4c4..690c5db0348 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -1616,7 +1616,7 @@ function comment_get_display_page($cid, $node_type) { * @see comment_form_validate() * @see comment_form_submit() */ -function comment_form(&$form_state, $comment) { +function comment_form($form, &$form_state, $comment) { global $user; $op = isset($_POST['op']) ? $_POST['op'] : ''; @@ -1634,7 +1634,6 @@ function comment_form(&$form_state, $comment) { $comment += array('name' => '', 'mail' => '', 'homepage' => ''); $comment = (object) $comment; - $form = array(); if (isset($form_state['comment_preview'])) { $form += $form_state['comment_preview']; } diff --git a/modules/contact/contact.admin.inc b/modules/contact/contact.admin.inc index 04e9f57b539..dd05b866c54 100644 --- a/modules/contact/contact.admin.inc +++ b/modules/contact/contact.admin.inc @@ -39,7 +39,7 @@ function contact_admin_categories() { /** * Category edit page. */ -function contact_admin_edit($form_state = array(), $op, $contact = NULL) { +function contact_admin_edit($form, $form_state = array(), $op, $contact = NULL) { if (empty($contact) || $op == 'add') { $contact = array( @@ -138,7 +138,7 @@ function contact_admin_edit_submit($form, &$form_state) { /** * Category delete page. */ -function contact_admin_delete(&$form_state, $contact) { +function contact_admin_delete($form, &$form_state, $contact) { $form['contact'] = array( '#type' => 'value', diff --git a/modules/contact/contact.pages.inc b/modules/contact/contact.pages.inc index 93b534ee715..4c92105763b 100644 --- a/modules/contact/contact.pages.inc +++ b/modules/contact/contact.pages.inc @@ -171,7 +171,7 @@ function contact_personal_page($account) { /** * Form builder; the personal contact form. */ -function contact_personal_form(&$form_state, $recipient) { +function contact_personal_form($form, &$form_state, $recipient) { global $user; $form['#token'] = $user->name . $user->mail; $form['recipient'] = array('#type' => 'value', '#value' => $recipient); diff --git a/modules/dblog/dblog.admin.inc b/modules/dblog/dblog.admin.inc index 1eb27794e39..7f0547c56fb 100644 --- a/modules/dblog/dblog.admin.inc +++ b/modules/dblog/dblog.admin.inc @@ -274,7 +274,7 @@ function _dblog_format_message($dblog) { * @see dblog_filter_form_submit() * @see dblog_filter_form_validate() */ -function dblog_filter_form() { +function dblog_filter_form($form) { $filters = dblog_filters(); $form['filters'] = array( @@ -347,7 +347,7 @@ function dblog_filter_form_submit($form, &$form_state) { * @ingroup forms * @see dblog_clear_log_submit() */ -function dblog_clear_log_form() { +function dblog_clear_log_form($form) { $form['dblog_clear'] = array( '#type' => 'fieldset', '#title' => t('Clear log messages'), @@ -367,7 +367,7 @@ function dblog_clear_log_form() { /** * Submit callback: clear database with log messages. */ -function dblog_clear_log_submit(&$form_state, $form) { +function dblog_clear_log_submit() { db_delete('watchdog')->execute(); drupal_set_message(t('Database log cleared.')); } diff --git a/modules/field_ui/field_ui.admin.inc b/modules/field_ui/field_ui.admin.inc index 53ad0aacac8..6cdf699d449 100644 --- a/modules/field_ui/field_ui.admin.inc +++ b/modules/field_ui/field_ui.admin.inc @@ -65,7 +65,7 @@ function field_ui_inactive_message($bundle) { * * Allows fields and pseudo-fields to be re-ordered. */ -function field_ui_field_overview_form(&$form_state, $obj_type, $bundle) { +function field_ui_field_overview_form($form, &$form_state, $obj_type, $bundle) { $bundle = field_extract_bundle($obj_type, $bundle); field_ui_inactive_message($bundle); @@ -86,7 +86,7 @@ function field_ui_field_overview_form(&$form_state, $obj_type, $bundle) { // Store each default weight so that we can add the 'add new' rows after them. $weights = array(); - $form = array( + $form += array( '#tree' => TRUE, '#bundle' => $bundle, '#fields' => array_keys($instances), @@ -551,7 +551,7 @@ function field_ui_field_overview_form_submit($form, &$form_state) { * This form includes form widgets to select which fields appear in teaser and * full build modes, and how the field labels should be rendered. */ -function field_ui_display_overview_form(&$form_state, $obj_type, $bundle, $build_modes_selector = 'basic') { +function field_ui_display_overview_form($form, &$form_state, $obj_type, $bundle, $build_modes_selector = 'basic') { $bundle = field_extract_bundle($obj_type, $bundle); field_ui_inactive_message($bundle); @@ -563,7 +563,7 @@ function field_ui_display_overview_form(&$form_state, $obj_type, $bundle, $build $field_types = field_info_field_types(); $build_modes = field_ui_build_modes_tabs($entity, $build_modes_selector); - $form = array( + $form += array( '#tree' => TRUE, '#bundle' => $bundle, '#fields' => array_keys($instances), @@ -791,7 +791,7 @@ function field_ui_field_has_data($field) { /** * Menu callback; presents the field settings edit page. */ -function field_ui_field_settings_form(&$form_state, $obj_type, $bundle, $instance) { +function field_ui_field_settings_form($form, &$form_state, $obj_type, $bundle, $instance) { $bundle = field_extract_bundle($obj_type, $bundle); $field = field_info_field($instance['field_name']); @@ -897,7 +897,7 @@ function field_ui_field_settings_form_submit($form, &$form_state) { /** * Menu callback; select a widget for the field. */ -function field_ui_widget_type_form(&$form_state, $obj_type, $bundle, $instance) { +function field_ui_widget_type_form($form, &$form_state, $obj_type, $bundle, $instance) { $bundle = field_extract_bundle($obj_type, $bundle); $field = field_read_field($instance['field_name']); @@ -956,7 +956,7 @@ function field_ui_widget_type_form_submit($form, &$form_state) { /** * Menu callback; present a form for removing a field from a content type. */ -function field_ui_field_delete_form(&$form_state, $obj_type, $bundle, $instance) { +function field_ui_field_delete_form($form, &$form_state, $obj_type, $bundle, $instance) { $bundle = field_extract_bundle($obj_type, $bundle); $field = field_info_field($instance['field_name']); $admin_path = _field_ui_bundle_admin_path($bundle); @@ -1010,7 +1010,7 @@ function field_ui_field_delete_form_submit($form, &$form_state) { /** * Menu callback; presents the field instance edit page. */ -function field_ui_field_edit_form(&$form_state, $obj_type, $bundle, $instance) { +function field_ui_field_edit_form($form, &$form_state, $obj_type, $bundle, $instance) { $bundle = field_extract_bundle($obj_type, $bundle); $field = field_info_field($instance['field_name']); diff --git a/modules/field_ui/field_ui.api.php b/modules/field_ui/field_ui.api.php index 4c53faa3962..9a938fae9e8 100644 --- a/modules/field_ui/field_ui.api.php +++ b/modules/field_ui/field_ui.api.php @@ -85,7 +85,6 @@ function hook_field_instance_settings_form($field, $instance) { function hook_field_widget_settings_form($field, $instance) { $widget = $instance['widget']; $settings = $widget['settings']; - $form = array(); if ($widget['type'] == 'text_textfield') { $form['size'] = array( diff --git a/modules/file/tests/file_module_test.module b/modules/file/tests/file_module_test.module index f5d75b9319b..9fdf6ae1636 100644 --- a/modules/file/tests/file_module_test.module +++ b/modules/file/tests/file_module_test.module @@ -22,10 +22,8 @@ function file_module_test_menu() { return $items; } -function file_module_test_form($form_state) { - $form = array( - '#tree' => TRUE, - ); +function file_module_test_form($form, $form_state) { + $form['#tree'] = TRUE; $form['file'] = array( '#type' => 'managed_file', diff --git a/modules/filter/filter.admin.inc b/modules/filter/filter.admin.inc index 218273a047a..04c9ffa41dc 100644 --- a/modules/filter/filter.admin.inc +++ b/modules/filter/filter.admin.inc @@ -13,13 +13,12 @@ * @ingroup forms * @see filter_admin_overview_submit() */ -function filter_admin_overview() { - +function filter_admin_overview($form) { // Overview of all formats. $formats = filter_formats(); $error = FALSE; - $form = array('#tree' => TRUE); + $form['#tree'] = TRUE; foreach ($formats as $id => $format) { $roles = array(); foreach (user_roles() as $rid => $name) { @@ -111,7 +110,7 @@ function filter_admin_format_page($format = NULL) { * @see filter_admin_format_form_validate() * @see filter_admin_format_form_submit() */ -function filter_admin_format_form(&$form_state, $format) { +function filter_admin_format_form($form, &$form_state, $format) { $default = ($format->format == variable_get('filter_default_format', 1)); if ($default) { $help = t('All roles for the default format must be enabled and cannot be changed.'); @@ -219,7 +218,7 @@ function filter_admin_format_form_submit($form, &$form_state) { * @ingroup forms * @see filter_admin_delete_submit() */ -function filter_admin_delete(&$form_state, $format) { +function filter_admin_delete($form, &$form_state, $format) { if ($format) { if ($format->format != variable_get('filter_default_format', 1)) { $form['#format'] = $format; @@ -269,7 +268,7 @@ function filter_admin_configure_page($format) { * * @ingroup forms */ -function filter_admin_configure(&$form_state, $format) { +function filter_admin_configure($form, &$form_state, $format) { $filters = filter_list_format($format->format); $filter_info = filter_get_filters(); @@ -279,7 +278,7 @@ function filter_admin_configure(&$form_state, $format) { // Pass along stored filter settings and default settings, but also the // format object and all filters to allow for complex implementations. $defaults = (isset($filter_info[$name]['default settings']) ? $filter_info[$name]['default settings'] : array()); - $settings_form = $filter_info[$name]['settings callback']($form_state, $filters[$name], $defaults, $format, $filters); + $settings_form = $filter_info[$name]['settings callback']($form, $form_state, $filters[$name], $defaults, $format, $filters); if (isset($settings_form) && is_array($settings_form)) { $form['settings'][$name] = array( '#type' => 'fieldset', @@ -339,7 +338,7 @@ function filter_admin_order_page($format) { * @see theme_filter_admin_order() * @see filter_admin_order_submit() */ -function filter_admin_order(&$form_state, $format = NULL) { +function filter_admin_order($form, &$form_state, $format = NULL) { // Get list (with forced refresh). $filters = filter_list_format($format->format); diff --git a/modules/filter/filter.api.php b/modules/filter/filter.api.php index 8b5db79ca52..edf92a3bb3d 100644 --- a/modules/filter/filter.api.php +++ b/modules/filter/filter.api.php @@ -91,7 +91,7 @@ * format. * * @code - * function mymodule_filter_settings(&$form_state, $filter, $defaults) { + * function mymodule_filter_settings($form, &$form_state, $filter, $defaults) { * $form['mymodule_url_length'] = array( * '#type' => 'textfield', * '#title' => t('Maximum link text length'), diff --git a/modules/filter/filter.module b/modules/filter/filter.module index 59fc6d721a6..bffde6fdbcd 100644 --- a/modules/filter/filter.module +++ b/modules/filter/filter.module @@ -841,7 +841,7 @@ function filter_filter_info() { /** * Settings callback for the HTML filter. */ -function _filter_html_settings(&$form_state, $filter, $defaults) { +function _filter_html_settings($form, &$form_state, $filter, $defaults) { $form['allowed_html'] = array( '#type' => 'textfield', '#title' => t('Allowed HTML tags'), @@ -887,7 +887,7 @@ function _filter_html($text, $filter) { /** * Settings callback for URL filter. */ -function _filter_url_settings(&$form_state, $filter, $defaults) { +function _filter_url_settings($form, &$form_state, $filter, $defaults) { $form['filter_url_length'] = array( '#type' => 'textfield', '#title' => t('Maximum link text length'), diff --git a/modules/forum/forum.admin.inc b/modules/forum/forum.admin.inc index cc340ac8c11..95018e18ac5 100644 --- a/modules/forum/forum.admin.inc +++ b/modules/forum/forum.admin.inc @@ -27,7 +27,7 @@ function forum_form_main($type, $edit = array()) { * @ingroup forms * @see forum_form_submit() */ -function forum_form_forum(&$form_state, $edit = array()) { +function forum_form_forum($form, &$form_state, $edit = array()) { $edit += array( 'name' => '', 'description' => '', @@ -105,7 +105,7 @@ function forum_form_submit($form, &$form_state) { * @ingroup forms * @see forum_form_submit() */ -function forum_form_container(&$form_state, $edit = array()) { +function forum_form_container($form, &$form_state, $edit = array()) { $edit += array( 'name' => '', 'description' => '', @@ -160,7 +160,7 @@ function forum_form_container(&$form_state, $edit = array()) { * * @param $tid ID of the term to be deleted */ -function forum_confirm_delete(&$form_state, $tid) { +function forum_confirm_delete($form, &$form_state, $tid) { $term = taxonomy_term_load($tid); $form['tid'] = array('#type' => 'value', '#value' => $tid); @@ -186,8 +186,7 @@ function forum_confirm_delete_submit($form, &$form_state) { * * @see system_settings_form() */ -function forum_admin_settings() { - $form = array(); +function forum_admin_settings($form) { $number = drupal_map_assoc(array(5, 10, 15, 20, 25, 30, 35, 40, 50, 60, 80, 100, 150, 200, 250, 300, 350, 400, 500)); $form['forum_hot_topic'] = array('#type' => 'select', '#title' => t('Hot topic threshold'), @@ -215,12 +214,12 @@ function forum_admin_settings() { /** * Returns an overview list of existing forums and containers */ -function forum_overview(&$form_state) { +function forum_overview($form, &$form_state) { module_load_include('inc', 'taxonomy', 'taxonomy.admin'); $vid = variable_get('forum_nav_vocabulary', ''); $vocabulary = taxonomy_vocabulary_load($vid); - $form = taxonomy_overview_terms($form_state, $vocabulary); + $form = taxonomy_overview_terms($form, $form_state, $vocabulary); foreach (element_children($form) as $key) { if (isset($form[$key]['#term'])) { diff --git a/modules/image/image.admin.inc b/modules/image/image.admin.inc index 10faf677a34..559d954b9e4 100644 --- a/modules/image/image.admin.inc +++ b/modules/image/image.admin.inc @@ -35,17 +35,13 @@ function image_style_list() { * @see image_style_form_submit() * @see image_style_name_validate() */ -function image_style_form(&$form_state, $style) { +function image_style_form($form, &$form_state, $style) { $title = t('Edit %name style', array('%name' => $style['name'])); drupal_set_title($title, PASS_THROUGH); $form_state['image_style'] = $style; - $form = array( - '#tree' => TRUE, - '#attached' => array( - 'css' => array(drupal_get_path('module', 'image') . '/image.admin.css' => array('preprocess' => FALSE)), - ), - ); + $form['#tree'] = TRUE; + $form['#attached']['css'][drupal_get_path('module', 'image') . '/image.admin.css'] = array('preprocess' => FALSE); // Allow the name of the style to be changed. $form['name'] = array( @@ -187,9 +183,7 @@ function image_style_form_submit($form, &$form_state) { * @see image_style_add_form_submit() * @see image_style_name_validate() */ -function image_style_add_form(&$form_state) { - $form = array(); - +function image_style_add_form($form, &$form_state) { $form['name'] = array( '#type' => 'textfield', '#size' => '64', @@ -243,9 +237,8 @@ function image_style_name_validate($element, $form_state) { * @ingroup forms * @see image_style_delete_form_submit() */ -function image_style_delete_form($form_state, $style) { +function image_style_delete_form($form, $form_state, $style) { $form_state['image_style'] = $style; - $form = array(); $replacement_styles = array_diff_key(image_style_options(), array($style['name'] => '')); $replacement_styles[''] = t('No replacement, just delete'); @@ -298,7 +291,7 @@ function image_style_delete_form_submit($form, &$form_state) { * @see image_crop_form() * @see image_effect_form_submit() */ -function image_effect_form(&$form_state, $style, $effect) { +function image_effect_form($form, &$form_state, $style, $effect) { if (!empty($effect['data'])) { $title = t('Edit %label effect', array('%label' => $effect['label'])); } @@ -315,12 +308,8 @@ function image_effect_form(&$form_state, $style, $effect) { drupal_goto('admin/config/media/image-styles/edit/' . $style['name']); } - $form = array( - '#tree' => TRUE, - '#attached' => array( - 'css' => array(drupal_get_path('module', 'image') . '/image.admin.css' => array('preprocess' => FALSE)), - ), - ); + $form['#tree'] = TRUE; + $form['#attached']['css'][drupal_get_path('module', 'image') . '/image.admin.css'] = array('preprocess' => FALSE); if (function_exists($effect['form callback'])) { $form['data'] = call_user_func($effect['form callback'], $effect['data']); } @@ -365,11 +354,10 @@ function image_effect_form_submit($form, &$form_state) { * @ingroup forms * @see image_effect_delete_form_submit() */ -function image_effect_delete_form(&$form_state, $style, $effect) { +function image_effect_delete_form($form, &$form_state, $style, $effect) { $form_state['image_style'] = $style; $form_state['image_effect'] = $effect; - $form = array(); $question = t('Are you sure you want to delete the @effect effect from the %style style?', array('%style' => $style['name'], '@effect' => $effect['label'])); return confirm_form($form, $question, 'admin/config/media/image-styles/edit/' . $style['name'], '', t('Delete')); } diff --git a/modules/menu/menu.admin.inc b/modules/menu/menu.admin.inc index b6956743c93..42592fdd2bf 100644 --- a/modules/menu/menu.admin.inc +++ b/modules/menu/menu.admin.inc @@ -40,7 +40,7 @@ function theme_menu_admin_overview($title, $name, $description) { * Shows for one menu the menu links accessible to the current user and * relevant operations. */ -function menu_overview_form(&$form_state, $menu) { +function menu_overview_form($form, &$form_state, $menu) { global $menu_admin; $sql = " SELECT m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.title, m.title_callback, m.title_arguments, m.type, m.description, ml.* @@ -60,7 +60,7 @@ function menu_overview_form(&$form_state, $menu) { menu_tree_check_access($tree, $node_links); $menu_admin = FALSE; - $form = _menu_overview_tree_form($tree); + $form = array_merge($form, _menu_overview_tree_form($tree)); $form['#menu'] = $menu; if (element_children($form)) { $form['submit'] = array( @@ -243,7 +243,7 @@ function theme_menu_overview_form($form) { /** * Menu callback; Build the menu link editing form. */ -function menu_edit_item(&$form_state, $type, $item, $menu) { +function menu_edit_item($form, &$form_state, $type, $item, $menu) { $form['menu'] = array( '#type' => 'fieldset', @@ -404,7 +404,7 @@ function menu_edit_item_submit($form, &$form_state) { /** * Menu callback; Build the form that handles the adding/editing of a custom menu. */ -function menu_edit_menu(&$form_state, $type, $menu = array()) { +function menu_edit_menu($form, &$form_state, $type, $menu = array()) { $system_menus = menu_list_system_menus(); $menu += array('menu_name' => '', 'title' => '', 'description' => ''); @@ -497,7 +497,7 @@ function menu_delete_menu_page($menu) { /** * Build a confirm form for deletion of a custom menu. */ -function menu_delete_menu_confirm(&$form_state, $menu) { +function menu_delete_menu_confirm($form, &$form_state, $menu) { $form['#menu'] = $menu; $caption = ''; $num_links = db_query("SELECT COUNT(*) FROM {menu_links} WHERE menu_name = :menu", array(':menu' => $menu['menu_name']))->fetchField(); @@ -639,7 +639,7 @@ function menu_item_delete_page($item) { /** * Build a confirm form for deletion of a single menu link. */ -function menu_item_delete_form(&$form_state, $item) { +function menu_item_delete_form($form, &$form_state, $item) { $form['#item'] = $item; return confirm_form($form, t('Are you sure you want to delete the custom menu link %item?', array('%item' => $item['link_title'])), 'admin/structure/menu-customize/' . $item['menu_name']); } @@ -659,7 +659,7 @@ function menu_item_delete_form_submit($form, &$form_state) { /** * Menu callback; reset a single modified menu link. */ -function menu_reset_item_confirm(&$form_state, $item) { +function menu_reset_item_confirm($form, &$form_state, $item) { $form['item'] = array('#type' => 'value', '#value' => $item); return confirm_form($form, t('Are you sure you want to reset the link %item to its default values?', array('%item' => $item['link_title'])), 'admin/structure/menu-customize/' . $item['menu_name'], t('Any customizations will be lost. This action cannot be undone.'), t('Reset')); } diff --git a/modules/node/content_types.inc b/modules/node/content_types.inc index 8a5adaf93ba..c0a2951bcdb 100644 --- a/modules/node/content_types.inc +++ b/modules/node/content_types.inc @@ -57,7 +57,7 @@ function theme_node_admin_overview($name, $type) { /** * Generates the node type editing form. */ -function node_type_form(&$form_state, $type = NULL) { +function node_type_form($form, &$form_state, $type = NULL) { if (!isset($type->type)) { // This is a new type. Node module managed types are custom and unlocked. $type = node_type_set_defaults(array('custom' => 1, 'locked' => 0)); @@ -415,7 +415,7 @@ function node_type_reset($type) { /** * Menu callback; delete a single content type. */ -function node_type_delete_confirm(&$form_state, $type) { +function node_type_delete_confirm($form, &$form_state, $type) { $form['type'] = array('#type' => 'value', '#value' => $type->type); $form['name'] = array('#type' => 'value', '#value' => $type->name); diff --git a/modules/node/node.admin.inc b/modules/node/node.admin.inc index 054ee1a239f..6d0bea7e661 100644 --- a/modules/node/node.admin.inc +++ b/modules/node/node.admin.inc @@ -366,7 +366,7 @@ function _node_mass_update_batch_finished($success, $results, $operations) { /** * Menu callback: content administration. */ -function node_admin_content($form_state) { +function node_admin_content($form, $form_state) { if (isset($form_state['values']['operation']) && $form_state['values']['operation'] == 'delete') { return node_multiple_delete_confirm($form_state, array_filter($form_state['values']['nodes'])); } @@ -555,7 +555,7 @@ function theme_node_admin_nodes($form) { return $output; } -function node_multiple_delete_confirm(&$form_state, $nodes) { +function node_multiple_delete_confirm($form, &$form_state, $nodes) { $form['nodes'] = array('#prefix' => '