summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--includes/form.inc26
-rw-r--r--includes/locale.inc20
-rw-r--r--install.php12
-rw-r--r--modules/aggregator/aggregator.admin.inc10
-rw-r--r--modules/aggregator/aggregator.test20
-rw-r--r--modules/block/block.admin.inc16
-rw-r--r--modules/book/book.admin.inc3
-rw-r--r--modules/book/book.pages.inc4
-rw-r--r--modules/color/color.module9
-rw-r--r--modules/comment/comment.admin.inc7
-rw-r--r--modules/comment/comment.module3
-rw-r--r--modules/contact/contact.admin.inc4
-rw-r--r--modules/contact/contact.pages.inc2
-rw-r--r--modules/dblog/dblog.admin.inc6
-rw-r--r--modules/field_ui/field_ui.admin.inc16
-rw-r--r--modules/field_ui/field_ui.api.php1
-rw-r--r--modules/file/tests/file_module_test.module6
-rw-r--r--modules/filter/filter.admin.inc15
-rw-r--r--modules/filter/filter.api.php2
-rw-r--r--modules/filter/filter.module4
-rw-r--r--modules/forum/forum.admin.inc13
-rw-r--r--modules/image/image.admin.inc30
-rw-r--r--modules/menu/menu.admin.inc14
-rw-r--r--modules/node/content_types.inc4
-rw-r--r--modules/node/node.admin.inc4
-rw-r--r--modules/node/node.module3
-rw-r--r--modules/node/node.pages.inc8
-rw-r--r--modules/openid/openid.inc3
-rw-r--r--modules/openid/openid.pages.inc10
-rw-r--r--modules/path/path.admin.inc6
-rw-r--r--modules/poll/poll.module4
-rw-r--r--modules/profile/profile.admin.inc7
-rw-r--r--modules/search/search.admin.inc2
-rw-r--r--modules/search/search.api.php1
-rw-r--r--modules/search/search.module11
-rw-r--r--modules/simpletest/simpletest.pages.inc12
-rw-r--r--modules/simpletest/tests/browser_test.module4
-rw-r--r--modules/simpletest/tests/field_test.module4
-rw-r--r--modules/simpletest/tests/file_test.module2
-rw-r--r--modules/simpletest/tests/form.test27
-rw-r--r--modules/simpletest/tests/form_test.module71
-rw-r--r--modules/system/image.gd.inc1
-rw-r--r--modules/system/system.admin.inc16
-rw-r--r--modules/system/system.module8
-rw-r--r--modules/system/system.test2
-rw-r--r--modules/taxonomy/taxonomy.admin.inc33
-rw-r--r--modules/trigger/trigger.admin.inc4
-rw-r--r--modules/update/update.settings.inc4
-rw-r--r--modules/user/user.admin.inc4
-rw-r--r--modules/user/user.module29
-rw-r--r--modules/user/user.pages.inc7
51 files changed, 270 insertions, 264 deletions
diff --git a/includes/form.inc b/includes/form.inc
index 83e37c385..5ebd18b7c 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 8e803eb61..4962f2fd7 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 8b3e52ebe..b9f19f7a5 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 05efbe151..b1fc85a8d 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 b8ea4120f..16d5e64ca 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 <em>either</em> 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 <em>either</em> 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 91465f9ee..455b48b38 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 8af9b195c..d1745473a 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 3e139cd81..5909c5b58 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 7f470bb5d..67d7ba922 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 fcb1adf7a..2cd5966e4 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 e02f964f4..690c5db03 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 04e9f57b5..dd05b866c 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 93b534ee7..4c9210576 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 1eb27794e..7f0547c56 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 53ad0aaca..6cdf699d4 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 4c53faa39..9a938fae9 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 f5d75b931..9fdf6ae16 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 218273a04..04c9ffa41 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 8b5db79ca..edf92a3bb 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 59fc6d721..bffde6fdb 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 cc340ac8c..95018e18a 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 10faf677a..559d954b9 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 b6956743c..42592fdd2 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 8a5adaf93..c0a2951bc 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 054ee1a23..6d0bea7e6 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' => '<ul>', '#suffix' => '</ul>', '#tree' => TRUE);
// array_filter returns only elements with TRUE values
foreach ($nodes as $nid => $value) {
diff --git a/modules/node/node.module b/modules/node/node.module
index f7706603c..3b62d2db6 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -2719,11 +2719,8 @@ function _node_access_rebuild_batch_finished($success, $results, $operations) {
* Implement hook_form().
*/
function node_content_form($node, $form_state) {
-
$type = node_type_get_type($node);
- $form = array();
-
if ($type->has_title) {
$form['title'] = array(
'#type' => 'textfield',
diff --git a/modules/node/node.pages.inc b/modules/node/node.pages.inc
index 60168012b..a0bbf92b0 100644
--- a/modules/node/node.pages.inc
+++ b/modules/node/node.pages.inc
@@ -107,7 +107,7 @@ function node_object_prepare($node) {
/**
* Generate the node add/edit form array.
*/
-function node_form(&$form_state, $node) {
+function node_form($form, &$form_state, $node) {
global $user;
if (isset($form_state['node'])) {
@@ -453,7 +453,7 @@ function node_form_submit_build_node($form, &$form_state) {
/**
* Menu callback -- ask for confirmation of node deletion
*/
-function node_delete_confirm(&$form_state, $node) {
+function node_delete_confirm($form, &$form_state, $node) {
$form['nid'] = array(
'#type' => 'value',
'#value' => $node->nid,
@@ -536,7 +536,7 @@ function node_revision_overview($node) {
/**
* Ask for confirmation of the reversion to prevent against CSRF attacks.
*/
-function node_revision_revert_confirm($form_state, $node_revision) {
+function node_revision_revert_confirm($form, $form_state, $node_revision) {
$form['#node_revision'] = $node_revision;
return confirm_form($form, t('Are you sure you want to revert to the revision from %revision-date?', array('%revision-date' => format_date($node_revision->revision_timestamp))), 'node/' . $node_revision->nid . '/revisions', '', t('Revert'), t('Cancel'));
}
@@ -556,7 +556,7 @@ function node_revision_revert_confirm_submit($form, &$form_state) {
$form_state['redirect'] = 'node/' . $node_revision->nid . '/revisions';
}
-function node_revision_delete_confirm($form_state, $node_revision) {
+function node_revision_delete_confirm($form, $form_state, $node_revision) {
$form['#node_revision'] = $node_revision;
return confirm_form($form, t('Are you sure you want to delete the revision from %revision-date?', array('%revision-date' => format_date($node_revision->revision_timestamp))), 'node/' . $node_revision->nid . '/revisions', t('This action cannot be undone.'), t('Delete'), t('Cancel'));
}
diff --git a/modules/openid/openid.inc b/modules/openid/openid.inc
index d833830c6..bb90596a5 100644
--- a/modules/openid/openid.inc
+++ b/modules/openid/openid.inc
@@ -84,8 +84,7 @@ function openid_redirect($url, $message) {
exit;
}
-function openid_redirect_form(&$form_state, $url, $message) {
- $form = array();
+function openid_redirect_form($form, &$form_state, $url, $message) {
$form['#action'] = $url;
$form['#method'] = "post";
foreach ($message as $key => $value) {
diff --git a/modules/openid/openid.pages.inc b/modules/openid/openid.pages.inc
index bc76eef00..b900c413c 100644
--- a/modules/openid/openid.pages.inc
+++ b/modules/openid/openid.pages.inc
@@ -93,7 +93,7 @@ function openid_user_add_submit($form, &$form_state) {
/**
* Menu callback; Delete the specified OpenID identity from the system.
*/
-function openid_user_delete_form($form_state, $account, $aid = 0) {
+function openid_user_delete_form($form, $form_state, $account, $aid = 0) {
$authname = db_query("SELECT authname FROM {authmap} WHERE uid = :uid AND aid = :aid AND module = 'openid'", array(
':uid' => $account->uid,
':aid' => $aid,
@@ -102,14 +102,14 @@ function openid_user_delete_form($form_state, $account, $aid = 0) {
return confirm_form(array(), t('Are you sure you want to delete the OpenID %authname for %user?', array('%authname' => $authname, '%user' => $account->name)), 'user/' . $account->uid . '/openid');
}
-function openid_user_delete_form_submit(&$form_state, $form_values) {
+function openid_user_delete_form_submit($form, &$form_state) {
$query = db_delete('authmap')
- ->condition('uid', $form_state['#args'][0]->uid)
- ->condition('aid', $form_state['#args'][1])
+ ->condition('uid', $form_state['args'][0]->uid)
+ ->condition('aid', $form_state['args'][1])
->condition('module', 'openid')
->execute();
if ($query) {
drupal_set_message(t('OpenID deleted.'));
}
- $form_state['#redirect'] = 'user/' . $form_state['#args'][0]->uid . '/openid';
+ $form_state['#redirect'] = 'user/' . $form_state['args'][0]->uid . '/openid';
}
diff --git a/modules/path/path.admin.inc b/modules/path/path.admin.inc
index cccf5e649..7d341f048 100644
--- a/modules/path/path.admin.inc
+++ b/modules/path/path.admin.inc
@@ -98,7 +98,7 @@ function path_admin_edit($pid = 0) {
* @see path_admin_form_validate()
* @see path_admin_form_submit()
*/
-function path_admin_form(&$form_state, $edit = array('src' => '', 'dst' => '', 'language' => '', 'pid' => NULL)) {
+function path_admin_form($form, &$form_state, $edit = array('src' => '', 'dst' => '', 'language' => '', 'pid' => NULL)) {
$form['#alias'] = $edit;
@@ -180,7 +180,7 @@ function path_admin_form_submit($form, &$form_state) {
/**
* Menu callback; confirms deleting an URL alias
*/
-function path_admin_delete_confirm($form_state, $pid) {
+function path_admin_delete_confirm($form, $form_state, $pid) {
$path = path_load($pid);
if (user_access('administer url aliases')) {
$form['pid'] = array('#type' => 'value', '#value' => $pid);
@@ -209,7 +209,7 @@ function path_admin_delete_confirm_submit($form, &$form_state) {
* @ingroup forms
* @see path_admin_filter_form_submit()
*/
-function path_admin_filter_form(&$form_state, $keys = '') {
+function path_admin_filter_form($form, &$form_state, $keys = '') {
$form['#attributes'] = array('class' => array('search-form'));
$form['basic'] = array('#type' => 'fieldset',
'#title' => t('Filter aliases')
diff --git a/modules/poll/poll.module b/modules/poll/poll.module
index 83f4c0a65..5a114d96f 100644
--- a/modules/poll/poll.module
+++ b/modules/poll/poll.module
@@ -628,7 +628,7 @@ function poll_teaser($node) {
* @see poll_vote()
* @see phptemplate_preprocess_poll_vote()
*/
-function poll_view_voting(&$form_state, $node, $block = FALSE) {
+function poll_view_voting($form, &$form_state, $node, $block = FALSE) {
if ($node->choice) {
$list = array();
foreach ($node->choice as $i => $choice) {
@@ -837,7 +837,7 @@ function template_preprocess_poll_bar(&$variables) {
* @ingroup forms
* @see poll_cancel()
*/
-function poll_cancel_form(&$form_state, $nid) {
+function poll_cancel_form($form, &$form_state, $nid) {
// Store the nid so we can get to it in submit functions.
$form['#nid'] = $nid;
diff --git a/modules/profile/profile.admin.inc b/modules/profile/profile.admin.inc
index df07bdeec..b01d7a0be 100644
--- a/modules/profile/profile.admin.inc
+++ b/modules/profile/profile.admin.inc
@@ -12,10 +12,9 @@
* @ingroup forms
* @see profile_admin_overview_submit()
*/
-function profile_admin_overview() {
+function profile_admin_overview($form) {
$result = db_query('SELECT title, name, type, category, fid, weight FROM {profile_field} ORDER BY category, weight');
- $form = array();
$categories = array();
foreach ($result as $field) {
// Collect all category information
@@ -170,7 +169,7 @@ function theme_profile_admin_overview($form) {
* @see profile_field_form_validate()
* @see profile_field_form_submit()
*/
-function profile_field_form(&$form_state, $arg = NULL) {
+function profile_field_form($form, &$form_state, $arg = NULL) {
if (arg(4) == 'edit') {
if (is_numeric($arg)) {
$fid = $arg;
@@ -380,7 +379,7 @@ function profile_field_form_submit($form, &$form_state) {
/**
* Menu callback; deletes a field from all user profiles.
*/
-function profile_field_delete(&$form_state, $fid) {
+function profile_field_delete($form, &$form_state, $fid) {
$field = db_query("SELECT title FROM {profile_field} WHERE fid = :fid", array(':fid' => $fid))->fetchObject();
if (!$field) {
drupal_not_found();
diff --git a/modules/search/search.admin.inc b/modules/search/search.admin.inc
index d939ae42f..12782e9b5 100644
--- a/modules/search/search.admin.inc
+++ b/modules/search/search.admin.inc
@@ -55,7 +55,7 @@ function _search_get_module_names() {
* @see search_admin_settings_submit()
* @see search_admin_reindex_submit()
*/
-function search_admin_settings() {
+function search_admin_settings($form) {
// Collect some stats
$remaining = 0;
$total = 0;
diff --git a/modules/search/search.api.php b/modules/search/search.api.php
index 956151745..f7c7f2d7f 100644
--- a/modules/search/search.api.php
+++ b/modules/search/search.api.php
@@ -95,7 +95,6 @@ function hook_search_status() {
* @ingroup search
*/
function hook_search_admin() {
- $form = array();
// Output form for defining rank factor weights.
$form['content_ranking'] = array(
'#type' => 'fieldset',
diff --git a/modules/search/search.module b/modules/search/search.module
index 1fe90ca75..07f22a9b2 100644
--- a/modules/search/search.module
+++ b/modules/search/search.module
@@ -864,8 +864,7 @@ function search_get_keys() {
* @return
* An HTML string containing the search form.
*/
-function search_form(&$form_state, $action = '', $keys = '', $type = NULL, $prompt = NULL) {
-
+function search_form($form, &$form_state, $action = '', $keys = '', $type = NULL, $prompt = NULL) {
// Add CSS
drupal_add_css(drupal_get_path('module', 'search') . '/search.css', array('preprocess' => FALSE));
@@ -876,10 +875,8 @@ function search_form(&$form_state, $action = '', $keys = '', $type = NULL, $prom
$prompt = t('Enter your keywords');
}
- $form = array(
- '#action' => $action,
- '#attributes' => array('class' => array('search-form')),
- );
+ $form['#action'] = $action;
+ $form['#attributes']['class'][] = 'search-form';
$form['module'] = array('#type' => 'value', '#value' => $type);
$form['basic'] = array('#type' => 'item', '#title' => $prompt, '#id' => 'edit-keys');
$form['basic']['inline'] = array('#prefix' => '<div class="container-inline">', '#suffix' => '</div>');
@@ -906,7 +903,7 @@ function search_form(&$form_state, $action = '', $keys = '', $type = NULL, $prom
* @see search-theme-form.tpl.php
* @see search-block-form.tpl.php
*/
-function search_box(&$form_state, $form_id) {
+function search_box($form, &$form_state, $form_id) {
$form[$form_id] = array(
'#title' => t('Search this site'),
'#type' => 'textfield',
diff --git a/modules/simpletest/simpletest.pages.inc b/modules/simpletest/simpletest.pages.inc
index ffef07a71..cb5ccfefc 100644
--- a/modules/simpletest/simpletest.pages.inc
+++ b/modules/simpletest/simpletest.pages.inc
@@ -9,9 +9,7 @@
/**
* List tests arranged in groups that can be selected and run.
*/
-function simpletest_test_form() {
- $form = array();
-
+function simpletest_test_form($form) {
$form['tests'] = array(
'#type' => 'fieldset',
'#title' => t('Tests'),
@@ -196,9 +194,7 @@ function simpletest_test_form_submit($form, &$form_state) {
/**
* Test results form for $test_id.
*/
-function simpletest_result_form(&$form_state, $test_id) {
- $form = array();
-
+function simpletest_result_form($form, &$form_state, $test_id) {
// Make sure there are test results to display and a re-run is not being performed.
$results = array();
if (is_numeric($test_id) && !$results = simpletest_result_get($test_id)) {
@@ -417,9 +413,7 @@ function simpletest_result_status_image($status) {
/**
* Provides settings form for SimpleTest variables.
*/
-function simpletest_settings_form(&$form_state) {
- $form = array();
-
+function simpletest_settings_form($form, &$form_state) {
$form['general'] = array(
'#type' => 'fieldset',
'#title' => t('General'),
diff --git a/modules/simpletest/tests/browser_test.module b/modules/simpletest/tests/browser_test.module
index b4c02680d..4d4fd24a3 100644
--- a/modules/simpletest/tests/browser_test.module
+++ b/modules/simpletest/tests/browser_test.module
@@ -39,9 +39,7 @@ function browser_test_print_get() {
exit;
}
-function browser_test_print_post_form(&$form_state) {
- $form = array();
-
+function browser_test_print_post_form($form, &$form_state) {
$form['foo'] = array(
'#type' => 'textfield',
);
diff --git a/modules/simpletest/tests/field_test.module b/modules/simpletest/tests/field_test.module
index fb711de78..642d7878e 100644
--- a/modules/simpletest/tests/field_test.module
+++ b/modules/simpletest/tests/field_test.module
@@ -256,9 +256,7 @@ function field_test_entity_edit($entity) {
/**
* Form to set the value of fields attached to our entity.
*/
-function field_test_entity_form(&$form_state, $entity) {
- $form = array();
-
+function field_test_entity_form($form, &$form_state, $entity) {
if (isset($form_state['test_entity'])) {
$entity = $form_state['test_entity'] + (array)$entity;
}
diff --git a/modules/simpletest/tests/file_test.module b/modules/simpletest/tests/file_test.module
index b0ae582fd..567508a4f 100644
--- a/modules/simpletest/tests/file_test.module
+++ b/modules/simpletest/tests/file_test.module
@@ -44,7 +44,7 @@ function file_test_stream_wrappers() {
/**
* Form to test file uploads.
*/
-function _file_test_form(&$form_state) {
+function _file_test_form($form, &$form_state) {
$form['file_test_upload'] = array(
'#type' => 'file',
'#title' => t('Upload an image'),
diff --git a/modules/simpletest/tests/form.test b/modules/simpletest/tests/form.test
index 6ea494c3d..5ee6252c1 100644
--- a/modules/simpletest/tests/form.test
+++ b/modules/simpletest/tests/form.test
@@ -449,3 +449,30 @@ class FormsFormStorageTestCase extends DrupalWebTestCase {
$this->assertPattern('/value_is_set/', t("The input values have been kept."));
}
}
+
+/**
+ * Test wrapper form callbacks.
+ */
+class FormsFormWrapperTestCase extends DrupalWebTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Form wrapper callback',
+ 'description' => 'Tests form wrapper callbacks to pass a prebuilt form to form builder functions.',
+ 'group' => 'Form API',
+ );
+ }
+
+ function setUp() {
+ parent::setUp('form_test');
+ }
+
+ /**
+ * Tests using the form in a usual way.
+ */
+ function testWrapperCallback() {
+ $this->drupalGet('form_test/wrapper-callback');
+ $this->assertText('Form wrapper callback element output.', t('The form contains form wrapper elements.'));
+ $this->assertText('Form builder element output.', t('The form contains form builder elements.'));
+ }
+}
+
diff --git a/modules/simpletest/tests/form_test.module b/modules/simpletest/tests/form_test.module
index 6646e85a8..6d6fd38f8 100644
--- a/modules/simpletest/tests/form_test.module
+++ b/modules/simpletest/tests/form_test.module
@@ -10,8 +10,6 @@
* Implement hook_menu().
*/
function form_test_menu() {
- $items = array();
-
$items['form_test/tableselect/multiple-true'] = array(
'title' => 'Tableselect checkboxes test',
'page callback' => 'drupal_get_form',
@@ -19,7 +17,6 @@ function form_test_menu() {
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
);
-
$items['form_test/tableselect/multiple-false'] = array(
'title' => 'Tableselect radio button test',
'page callback' => 'drupal_get_form',
@@ -27,7 +24,6 @@ function form_test_menu() {
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
);
-
$items['form_test/tableselect/empty-text'] = array(
'title' => 'Tableselect empty text test',
'page callback' => 'drupal_get_form',
@@ -35,7 +31,6 @@ function form_test_menu() {
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
);
-
$items['form_test/tableselect/advanced-select'] = array(
'title' => 'Tableselect js_select tests',
'page callback' => 'drupal_get_form',
@@ -66,6 +61,14 @@ function form_test_menu() {
'type' => MENU_CALLBACK,
);
+ $items['form_test/wrapper-callback'] = array(
+ 'title' => 'Form wrapper callback test',
+ 'page callback' => 'form_test_wrapper_callback',
+ 'page arguments' => array('form_test_wrapper_callback_form'),
+ 'access arguments' => array('access content'),
+ 'type' => MENU_CALLBACK,
+ );
+
return $items;
}
@@ -82,7 +85,7 @@ function form_test_form_clean_id_page() {
/**
* A simple form to test clean_id generation.
*/
-function form_test_test_form(&$form_state) {
+function form_test_test_form($form, &$form_state) {
$form['input'] = array(
'#type' => 'item',
'#title' => 'Test Textfield',
@@ -137,9 +140,7 @@ function _form_test_tableselect_get_data() {
* @return
* A form with a tableselect element and a submit button.
*/
-function _form_test_tableselect_form_builder($form_state, $element_properties) {
- $form = array();
-
+function _form_test_tableselect_form_builder($form, $form_state, $element_properties) {
list($header, $options) = _form_test_tableselect_get_data();
$form['tableselect'] = $element_properties;
@@ -163,8 +164,8 @@ function _form_test_tableselect_form_builder($form_state, $element_properties) {
/**
* Test the tableselect #multiple = TRUE functionality.
*/
-function _form_test_tableselect_multiple_true_form($form_state) {
- return _form_test_tableselect_form_builder($form_state, array('#multiple' => TRUE));
+function _form_test_tableselect_multiple_true_form($form, $form_state) {
+ return _form_test_tableselect_form_builder($form, $form_state, array('#multiple' => TRUE));
}
/**
@@ -180,8 +181,8 @@ function _form_test_tableselect_multiple_true_form_submit($form, &$form_state) {
/**
* Test the tableselect #multiple = FALSE functionality.
*/
-function _form_test_tableselect_multiple_false_form($form_state) {
- return _form_test_tableselect_form_builder($form_state, array('#multiple' => FALSE));
+function _form_test_tableselect_multiple_false_form($form, $form_state) {
+ return _form_test_tableselect_form_builder($form, $form_state, array('#multiple' => FALSE));
}
/**
@@ -194,17 +195,15 @@ function _form_test_tableselect_multiple_false_form_submit($form, &$form_state)
/**
* Test functionality of the tableselect #empty property.
*/
-function _form_test_tableselect_empty_form($form_state) {
- return _form_test_tableselect_form_builder($form_state, array('#options' => array()));
+function _form_test_tableselect_empty_form($form, $form_state) {
+ return _form_test_tableselect_form_builder($form, $form_state, array('#options' => array()));
}
/**
* Test functionality of the tableselect #js_select property.
*/
-function _form_test_tableselect_js_select_form($form_state, $action) {
-
+function _form_test_tableselect_js_select_form($form, $form_state, $action) {
switch ($action) {
-
case 'multiple-true-default':
$options = array('#multiple' => TRUE);
break;
@@ -222,7 +221,7 @@ function _form_test_tableselect_js_select_form($form_state, $action) {
break;
}
- return _form_test_tableselect_form_builder($form_state, $options);
+ return _form_test_tableselect_form_builder($form, $form_state, $options);
}
/**
@@ -263,9 +262,7 @@ function form_test_batch_callback($value) {
/**
* A simple form with a textfield and submit button.
*/
-function form_test_mock_form($form_state) {
- $form = array();
-
+function form_test_mock_form($form, $form_state) {
$form['test_value'] = array(
'#type' => 'textfield',
'#default_value' => 'initial_state',
@@ -298,7 +295,7 @@ function form_test_mock_form_submit($form, &$form_state) {
*
* @see form_storage_test_form_submit().
*/
-function form_storage_test_form(&$form_state) {
+function form_storage_test_form($form, &$form_state) {
// Initialize
if (!isset($form_state['storage'])) {
if (empty($form_state['input'])) {
@@ -365,3 +362,31 @@ function form_storage_test_form_submit($form, &$form_state) {
$form_state['storage']['step']++;
drupal_set_message("Form constructions: ". $_SESSION['constructions']);
}
+
+/**
+ * Menu callback; Invokes a form builder function with a wrapper callback.
+ */
+function form_test_wrapper_callback($form_id) {
+ $form_state = array(
+ 'args' => array(),
+ 'wrapper_callback' => 'form_test_wrapper_callback_wrapper',
+ );
+ return drupal_build_form($form_id, $form_state);
+}
+
+/**
+ * Form wrapper for form_test_wrapper_callback_form().
+ */
+function form_test_wrapper_callback_wrapper($form, &$form_state) {
+ $form['wrapper'] = array('#markup' => 'Form wrapper callback element output.');
+ return $form;
+}
+
+/**
+ * Form builder for form wrapper callback test.
+ */
+function form_test_wrapper_callback_form($form, &$form_state) {
+ $form['builder'] = array('#markup' => 'Form builder element output.');
+ return $form;
+}
+
diff --git a/modules/system/image.gd.inc b/modules/system/image.gd.inc
index e6c70e76b..d1b888e41 100644
--- a/modules/system/image.gd.inc
+++ b/modules/system/image.gd.inc
@@ -16,7 +16,6 @@
*/
function image_gd_settings() {
if (image_gd_check_settings()) {
- $form = array();
$form['status'] = array(
'#markup' => t('The GD toolkit is installed and working properly.')
);
diff --git a/modules/system/system.admin.inc b/modules/system/system.admin.inc
index b4aa10446..d7c380f9d 100644
--- a/modules/system/system.admin.inc
+++ b/modules/system/system.admin.inc
@@ -378,7 +378,7 @@ function system_themes_form_submit($form, &$form_state) {
* @ingroup forms
* @see system_theme_settings_submit()
*/
-function system_theme_settings(&$form_state, $key = '') {
+function system_theme_settings($form, &$form_state, $key = '') {
$directory_path = file_directory_path();
if (!file_prepare_directory($directory_path, FILE_CREATE_DIRECTORY)) {
drupal_set_message(t('The directory %directory does not exist or is not writable.', array('%directory' => $directory_path)), 'warning');
@@ -633,7 +633,7 @@ function _system_is_incompatible(&$incompatible, $files, $file) {
* @return
* The form array.
*/
-function system_modules($form_state = array()) {
+function system_modules($form, $form_state = array()) {
// Get current list of modules.
$files = system_get_module_data();
@@ -834,7 +834,6 @@ function _system_modules_build_row($info, $extra) {
* @ingroup forms
*/
function system_modules_confirm_form($modules, $storage) {
- $form = array();
$items = array();
$form['validation_modules'] = array('#type' => 'value', '#value' => $modules);
@@ -1034,7 +1033,7 @@ function system_modules_submit($form, &$form_state) {
* @return
* A form array representing the currently disabled modules.
*/
-function system_modules_uninstall($form_state = NULL) {
+function system_modules_uninstall($form, $form_state = NULL) {
// Make sure the install API is available.
include_once DRUPAL_ROOT . '/includes/install.inc';
@@ -1043,12 +1042,9 @@ function system_modules_uninstall($form_state = NULL) {
return $confirm_form;
}
- $form = array();
-
// Pull all disabled modules from the system table.
$disabled_modules = db_query("SELECT name, filename, info FROM {system} WHERE type = 'module' AND status = 0 AND schema_version > :schema ORDER BY name", array(':schema' => SCHEMA_UNINSTALLED));
foreach ($disabled_modules as $module) {
-
// Grab the module info
$info = unserialize($module->info);
@@ -1186,7 +1182,7 @@ function system_ip_blocking() {
* @see system_ip_blocking_form_validate()
* @see system_ip_blocking_form_submit()
*/
-function system_ip_blocking_form($form_state) {
+function system_ip_blocking_form($form, $form_state) {
$form['ip'] = array(
'#title' => t('IP address'),
'#type' => 'textfield',
@@ -1232,7 +1228,7 @@ function system_ip_blocking_form_submit($form, &$form_state) {
*
* @see system_ip_blocking_delete_submit()
*/
-function system_ip_blocking_delete(&$form_state, $iid) {
+function system_ip_blocking_delete($form, &$form_state, $iid) {
$form['blocked_ip'] = array(
'#type' => 'value',
'#value' => $iid,
@@ -1826,7 +1822,7 @@ function system_site_maintenance_mode() {
* @ingroup forms
* @see system_settings_form()
*/
-function system_clean_url_settings() {
+function system_clean_url_settings($form) {
global $base_url;
// When accessing this form using a non-clean URL, allow a re-check to make
diff --git a/modules/system/system.module b/modules/system/system.module
index 5204141c0..867ec7213 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -1392,8 +1392,6 @@ function system_filetransfer_backend_form_ssh() {
* Helper function because SSH and FTP backends share the same elements
*/
function _system_filetransfer_backend_form_common() {
- $form = array();
-
$form['hostname'] = array (
'#type' => 'textfield',
'#title' => t('Host'),
@@ -2536,7 +2534,7 @@ function system_actions_manage() {
* @return
* Form definition.
*/
-function system_actions_manage_form($form_state, $options = array()) {
+function system_actions_manage_form($form, $form_state, $options = array()) {
$form['parent'] = array(
'#type' => 'fieldset',
'#title' => t('Make a new advanced action available'),
@@ -2582,7 +2580,7 @@ function system_actions_manage_form_submit($form, &$form_state) {
* @return
* Form definition.
*/
-function system_actions_configure($form_state, $action = NULL) {
+function system_actions_configure($form, &$form_state, $action = NULL) {
if ($action === NULL) {
drupal_goto('admin/config/system/actions');
}
@@ -2685,7 +2683,7 @@ function system_actions_configure_submit($form, &$form_state) {
* @ingroup forms
* @see system_actions_delete_form_submit()
*/
-function system_actions_delete_form($form_state, $action) {
+function system_actions_delete_form($form, $form_state, $action) {
$form['aid'] = array(
'#type' => 'hidden',
diff --git a/modules/system/system.test b/modules/system/system.test
index 58d60b253..d6fd1a98e 100644
--- a/modules/system/system.test
+++ b/modules/system/system.test
@@ -966,8 +966,6 @@ class SystemSettingsForm extends DrupalWebTestCase {
* Tests the handling of automatic defaults in systems_settings_form().
*/
function testAutomaticDefaults() {
- $form = array();
-
$form['system_settings_form_test'] = array(
'#type' => 'checkbox',
'#default_value' => FALSE,
diff --git a/modules/taxonomy/taxonomy.admin.inc b/modules/taxonomy/taxonomy.admin.inc
index ab011aa64..ee32be4b0 100644
--- a/modules/taxonomy/taxonomy.admin.inc
+++ b/modules/taxonomy/taxonomy.admin.inc
@@ -13,9 +13,9 @@
* @see taxonomy_overview_vocabularies_submit()
* @see theme_taxonomy_overview_vocabularies()
*/
-function taxonomy_overview_vocabularies() {
+function taxonomy_overview_vocabularies($form) {
$vocabularies = taxonomy_get_vocabularies();
- $form = array('#tree' => TRUE);
+ $form['#tree'] = TRUE;
foreach ($vocabularies as $vocabulary) {
$types = array();
foreach ($vocabulary->nodes as $type) {
@@ -102,7 +102,7 @@ function theme_taxonomy_overview_vocabularies($form) {
* @ingroup forms
* @see taxonomy_form_vocabulary_submit()
*/
-function taxonomy_form_vocabulary(&$form_state, $edit = array()) {
+function taxonomy_form_vocabulary($form, &$form_state, $edit = array()) {
if (!is_array($edit)) {
$edit = (array)$edit;
}
@@ -121,7 +121,7 @@ function taxonomy_form_vocabulary(&$form_state, $edit = array()) {
$form['#vocabulary'] = (object) $edit;
// Check whether we need a deletion confirmation form.
if (isset($form_state['confirm_delete']) && isset($form_state['values']['vid'])) {
- return taxonomy_vocabulary_confirm_delete($form_state, $form_state['values']['vid']);
+ return taxonomy_vocabulary_confirm_delete($form, $form_state, $form_state['values']['vid']);
}
$form['name'] = array(
'#type' => 'textfield',
@@ -278,7 +278,7 @@ function taxonomy_form_vocabulary_submit($form, &$form_state) {
* @see taxonomy_overview_terms_submit()
* @see theme_taxonomy_overview_terms()
*/
-function taxonomy_overview_terms(&$form_state, $vocabulary) {
+function taxonomy_overview_terms($form, &$form_state, $vocabulary) {
global $pager_page_array, $pager_total, $pager_total_items;
// Check for confirmation forms.
@@ -286,11 +286,9 @@ function taxonomy_overview_terms(&$form_state, $vocabulary) {
return taxonomy_vocabulary_confirm_reset_alphabetical($form_state, $vocabulary->vid);
}
- $form = array(
- '#vocabulary' => $vocabulary,
- '#tree' => TRUE,
- '#parent_fields' => FALSE,
- );
+ $form['#vocabulary'] = $vocabulary;
+ $form['#tree'] = TRUE;
+ $form['#parent_fields'] = FALSE;
$page = isset($_GET['page']) ? $_GET['page'] : 0;
$page_increment = variable_get('taxonomy_terms_per_page_admin', 100); // Number of terms per page.
@@ -677,7 +675,7 @@ function theme_taxonomy_overview_terms($form) {
* @ingroup forms
* @see taxonomy_form_term_submit()
*/
-function taxonomy_form_term(&$form_state, $vocabulary, $edit = array()) {
+function taxonomy_form_term($form, &$form_state, $vocabulary, $edit = array()) {
$edit += array(
'name' => '',
'description' => '',
@@ -700,10 +698,10 @@ function taxonomy_form_term(&$form_state, $vocabulary, $edit = array()) {
// Check for confirmation forms.
if (isset($form_state['confirm_delete'])) {
- return array_merge($form, taxonomy_term_confirm_delete($form_state, $edit['tid']));
+ return array_merge($form, taxonomy_term_confirm_delete($form, $form_state, $edit['tid']));
}
elseif (isset($form_state['confirm_parents'])) {
- return array_merge($form, taxonomy_term_confirm_parents($form_state, $vocabulary));
+ return array_merge($form, taxonomy_term_confirm_parents($form, $form_state, $vocabulary));
}
$form['identification'] = array(
@@ -885,8 +883,7 @@ function taxonomy_form_term_submit_builder($form, &$form_state) {
* @ingroup forms
* @see taxonomy_form_term()
*/
-function taxonomy_term_confirm_parents(&$form_state, $vocabulary) {
- $form = array();
+function taxonomy_term_confirm_parents($form, &$form_state, $vocabulary) {
foreach (element_children($form_state['values']) as $key) {
$form[$key] = array(
'#type' => 'value',
@@ -905,7 +902,7 @@ function taxonomy_term_confirm_parents(&$form_state, $vocabulary) {
* @ingroup forms
* @see taxonomy_term_confirm_delete_submit()
*/
-function taxonomy_term_confirm_delete(&$form_state, $tid) {
+function taxonomy_term_confirm_delete($form, &$form_state, $tid) {
$term = taxonomy_term_load($tid);
$form['type'] = array('#type' => 'value', '#value' => 'term');
@@ -942,7 +939,7 @@ function taxonomy_term_confirm_delete_submit($form, &$form_state) {
* @ingroup forms
* @see taxonomy_vocabulary_confirm_delete_submit()
*/
-function taxonomy_vocabulary_confirm_delete(&$form_state, $vid) {
+function taxonomy_vocabulary_confirm_delete($form, &$form_state, $vid) {
$vocabulary = taxonomy_vocabulary_load($vid);
$form['#id'] = 'taxonomy_vocabulary_confirm_delete';
@@ -978,7 +975,7 @@ function taxonomy_vocabulary_confirm_delete_submit($form, &$form_state) {
* @ingroup forms
* @see taxonomy_vocabulary_confirm_reset_alphabetical_submit()
*/
-function taxonomy_vocabulary_confirm_reset_alphabetical(&$form_state, $vid) {
+function taxonomy_vocabulary_confirm_reset_alphabetical($form, &$form_state, $vid) {
$vocabulary = taxonomy_vocabulary_load($vid);
$form['type'] = array('#type' => 'value', '#value' => 'vocabulary');
diff --git a/modules/trigger/trigger.admin.inc b/modules/trigger/trigger.admin.inc
index 2ab8cf764..5e4c3f408 100644
--- a/modules/trigger/trigger.admin.inc
+++ b/modules/trigger/trigger.admin.inc
@@ -46,7 +46,7 @@ function trigger_assign($type = NULL) {
* @ingroup forms
* @see trigger_unassign_submit()
*/
-function trigger_unassign($form_state, $hook = NULL, $op = NULL, $aid = NULL) {
+function trigger_unassign($form, $form_state, $hook = NULL, $op = NULL, $aid = NULL) {
if (!($hook && $op && $aid)) {
drupal_goto('admin/structure/trigger/assign');
}
@@ -114,7 +114,7 @@ function trigger_unassign_submit($form, &$form_state) {
* @see trigger_assign_form_validate()
* @see trigger_assign_form_submit()
*/
-function trigger_assign_form($form_state, $hook, $op, $description) {
+function trigger_assign_form($form, $form_state, $hook, $op, $description) {
$form['hook'] = array(
'#type' => 'hidden',
'#value' => $hook,
diff --git a/modules/update/update.settings.inc b/modules/update/update.settings.inc
index 074f41515..38233ed20 100644
--- a/modules/update/update.settings.inc
+++ b/modules/update/update.settings.inc
@@ -9,9 +9,7 @@
/**
* Form builder for the update settings tab.
*/
-function update_settings() {
- $form = array();
-
+function update_settings($form) {
$notify_emails = variable_get('update_notify_emails', array());
$form['update_notify_emails'] = array(
'#type' => 'textarea',
diff --git a/modules/user/user.admin.inc b/modules/user/user.admin.inc
index d68da2410..8b944d324 100644
--- a/modules/user/user.admin.inc
+++ b/modules/user/user.admin.inc
@@ -206,7 +206,7 @@ function user_admin_account() {
* Submit the user administration update form.
*/
function user_admin_account_submit($form, &$form_state) {
- $operations = module_invoke_all('user_operations', $form_state);
+ $operations = module_invoke_all('user_operations', $form, $form_state);
$operation = $operations[$form_state['values']['operation']];
// Filter out unchecked accounts.
$accounts = array_filter($form_state['values']['accounts']);
@@ -602,7 +602,7 @@ function user_admin_settings() {
* @see user_admin_permissions_submit()
* @see theme_user_admin_permissions()
*/
-function user_admin_permissions($form_state, $rid = NULL) {
+function user_admin_permissions($form, $form_state, $rid = NULL) {
// Retrieve role names for columns.
$role_names = user_roles();
diff --git a/modules/user/user.module b/modules/user/user.module
index d143c6366..fabed7b80 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -864,8 +864,9 @@ function user_user_view($account) {
*/
function user_user_form(&$edit, $account, $category) {
if ($category == 'account') {
+ $form = array();
$form_state = array();
- return user_edit_form($form_state, (isset($account->uid) ? $account->uid : FALSE), $edit);
+ return user_edit_form($form, $form_state, (isset($account->uid) ? $account->uid : FALSE), $edit);
}
}
@@ -943,13 +944,11 @@ function user_user_categories() {
));
}
-function user_login_block() {
- $form = array(
- '#action' => url($_GET['q'], array('query' => drupal_get_destination())),
- '#id' => 'user-login-form',
- '#validate' => user_login_default_validators(),
- '#submit' => array('user_login_submit'),
- );
+function user_login_block($form) {
+ $form['#action'] = url($_GET['q'], array('query' => drupal_get_destination()));
+ $form['#id'] = 'user-login-form';
+ $form['#validate'] = user_login_default_validators();
+ $form['#submit'][] = 'user_login_submit';
$form['name'] = array('#type' => 'textfield',
'#title' => t('Username'),
'#maxlength' => USERNAME_MAX_LENGTH,
@@ -1544,7 +1543,7 @@ function user_set_authmaps($account, $authmaps) {
*
* @ingroup forms
*/
-function user_login(&$form_state) {
+function user_login($form, &$form_state) {
global $user;
// If we are already logged on, go to the user page instead.
@@ -1811,12 +1810,10 @@ function user_pass_rehash($password, $timestamp, $login) {
return md5($timestamp . $password . $login);
}
-function user_edit_form(&$form_state, $uid, $edit, $register = FALSE) {
+function user_edit_form($form, &$form_state, $uid, $edit, $register = FALSE) {
_user_password_dynamic_validation();
$admin = user_access('administer users');
- $form = array();
-
// Account information:
$form['account'] = array('#type' => 'fieldset',
'#title' => t('Account information'),
@@ -2351,7 +2348,7 @@ function user_role_set_permissions($role, array $permissions = array(), $merge =
/**
* Implement hook_user_operations().
*/
-function user_user_operations($form_state = array()) {
+function user_user_operations($form = array(), $form_state = array()) {
$operations = array(
'unblock' => array(
'label' => t('Unblock the selected users'),
@@ -2475,7 +2472,7 @@ function user_multiple_role_edit($accounts, $operation, $rid) {
}
}
-function user_multiple_cancel_confirm(&$form_state) {
+function user_multiple_cancel_confirm($form, &$form_state) {
$edit = $form_state['input'];
$form['accounts'] = array('#prefix' => '<ul>', '#suffix' => '</ul>', '#tree' => TRUE);
@@ -3041,7 +3038,7 @@ function user_register_submit($form, &$form_state) {
* @see user_register_validate()
* @see user_register_submit()
*/
-function user_register() {
+function user_register($form, &$form_state) {
global $user;
$admin = user_access('administer users');
@@ -3052,7 +3049,7 @@ function user_register() {
}
// Start with the default user edit fields.
- $form = user_edit_form($form_state, NULL, NULL, TRUE);
+ $form = user_edit_form($form, $form_state, NULL, NULL, TRUE);
if ($admin) {
$form['account']['notify'] = array(
'#type' => 'checkbox',
diff --git a/modules/user/user.pages.inc b/modules/user/user.pages.inc
index 43028f07e..ac1115a80 100644
--- a/modules/user/user.pages.inc
+++ b/modules/user/user.pages.inc
@@ -75,7 +75,7 @@ function user_pass_submit($form, &$form_state) {
/**
* Menu callback; process one time login link and redirects to the user page on success.
*/
-function user_pass_reset(&$form_state, $uid, $timestamp, $hashed_pass, $action = NULL) {
+function user_pass_reset($form, &$form_state, $uid, $timestamp, $hashed_pass, $action = NULL) {
global $user;
// When processing the one-time login link, we have to make sure that a user
@@ -225,7 +225,7 @@ function user_edit($account, $category = 'account') {
* @see user_profile_form_submit()
* @see user_cancel_confirm_form_submit()
*/
-function user_profile_form($form_state, $account, $category = 'account') {
+function user_profile_form($form, $form_state, $account, $category = 'account') {
global $user;
$edit = (empty($form_state['values'])) ? (array)$account : $form_state['values'];
@@ -306,7 +306,7 @@ function user_edit_cancel_submit($form, &$form_state) {
* @ingroup forms
* @see user_edit_cancel_submit()
*/
-function user_cancel_confirm_form(&$form_state, $account) {
+function user_cancel_confirm_form($form, &$form_state, $account) {
global $user;
$form['_account'] = array('#type' => 'value', '#value' => $account);
@@ -451,7 +451,6 @@ function user_cancel_methods() {
// Turn all methods into real form elements.
$default_method = variable_get('user_cancel_method', 'user_cancel_block');
- $form = array();
foreach ($methods as $name => $method) {
$form[$name] = array(
'#type' => 'radio',