function hook_form_alter

×

Error message

User warning: The following module is missing from the file system: theme/theme. For information about how to fix this, see the documentation page. in _drupal_trigger_error_with_delayed_logging() (line 1156 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
cis7 system.api.php hook_form_alter(&$form, &$form_state, $form_id)
cle7 system.api.php hook_form_alter(&$form, &$form_state, $form_id)
elmsmedia7 system.api.php hook_form_alter(&$form, &$form_state, $form_id)
icor7 system.api.php hook_form_alter(&$form, &$form_state, $form_id)
meedjum_blog7 system.api.php hook_form_alter(&$form, &$form_state, $form_id)
mooc7 system.api.php hook_form_alter(&$form, &$form_state, $form_id)

Perform alterations before a form is rendered.

One popular use of this hook is to add form elements to the node form. When altering a node form, the node object can be accessed at $form['#node'].

In addition to hook_form_alter(), which is called for all forms, there are two more specific form hooks available. The first, hook_form_BASE_FORM_ID_alter(), allows targeting of a form/forms via a base form (if one exists). The second, hook_form_FORM_ID_alter(), can be used to target a specific form directly.

The call order is as follows: all existing form alter functions are called for module A, then all for module B, etc., followed by all for any base theme(s), and finally for the theme itself. The module order is determined by system weight, then by module name.

Within each module, form alter hooks are called in the following order: first, hook_form_alter(); second, hook_form_BASE_FORM_ID_alter(); third, hook_form_FORM_ID_alter(). So, for each module, the more general hooks are called first followed by the more specific.

Parameters

$form: Nested array of form elements that comprise the form.

$form_state: A keyed array containing the current state of the form. The arguments that drupal_get_form() was originally called with are available in the array $form_state['build_info']['args'].

$form_id: String representing the name of the form itself. Typically this is the name of the function that generated the form.

See also

hook_form_BASE_FORM_ID_alter()

hook_form_FORM_ID_alter()

forms_api_reference.html

Related topics

171 functions implement hook_form_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

accessibility_content_field_widget_form_alter in sites/all/modules/ulmus/accessibility/modules/accessibility_content/accessibility_content.module
Implements field_widget_form_alter().
accessibility_content_form_field_ui_field_edit_form_alter in sites/all/modules/ulmus/accessibility/modules/accessibility_content/accessibility_content.module
Implements hook_form_FORM_ID_alter().
accessibility_reporting_form_field_ui_field_edit_form_alter in sites/all/modules/ulmus/accessibility/modules/accessibility_reporting/accessibility_reporting.module
Implements hook_form_FORM_ID_alter().
adaptivetheme_admin_form_alter in sites/all/themes/ulmus/adaptivetheme/at_admin/template.php
Alter the search block form.
adaptivetheme_form_alter in sites/all/themes/ulmus/adaptivetheme/at_core/inc/alter.inc
hook_form_FORM_alter()

... See full list

File

modules/system/system.api.php, line 1671
Hooks provided by Drupal core and the System module.

Code

function hook_form_alter(&$form, &$form_state, $form_id) {
  if (isset($form['type']) && $form['type']['#value'] . '_node_settings' == $form_id) {
    $form['workflow']['upload_' . $form['type']['#value']] = array(
      '#type' => 'radios',
      '#title' => t('Attachments'),
      '#default_value' => variable_get('upload_' . $form['type']['#value'], 1),
      '#options' => array(t('Disabled'), t('Enabled')),
    );
  }
}
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.