Commit df02fa3c authored by webchick's avatar webchick

#571086 by sun and merlinofchaos: Added a 'wrapper callback' that executes

before a form builder function, to facilitate common form elements. Clean-up
from form_builder changes from CTools patch. Has nice side-benefit of making
all form functions' signatures consistent.
parent e18feedf
......@@ -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.
......
......@@ -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'));
}
......
......@@ -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(
......
......@@ -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'],
......
......@@ -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'));
......
......@@ -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);
......
......@@ -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(
......
......@@ -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);
......
......@@ -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;
......
......@@ -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,
......
......@@ -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'];
}
......
......@@ -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',
......
......@@ -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);
......
......@@ -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.'));
}
......@@ -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']);
......
......@@ -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(
......
......@@ -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',
......
......@@ -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);
......
......@@ -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'),
......
......@@ -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'),
......
......@@ -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