summaryrefslogtreecommitdiff
path: root/modules/system/system.api.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules/system/system.api.php')
-rw-r--r--modules/system/system.api.php42
1 files changed, 41 insertions, 1 deletions
diff --git a/modules/system/system.api.php b/modules/system/system.api.php
index ebd4f20ed..c9b140167 100644
--- a/modules/system/system.api.php
+++ b/modules/system/system.api.php
@@ -1336,11 +1336,14 @@ function hook_form_alter(&$form, &$form_state, $form_id) {
* Nested array of form elements that comprise the form.
* @param $form_state
* A keyed array containing the current state of the form.
+ * @param $form_id
+ * String representing the name of the form itself. Typically this is the
+ * name of the function that generated the form.
*
* @see hook_form_alter()
* @see drupal_prepare_form()
*/
-function hook_form_FORM_ID_alter(&$form, &$form_state) {
+function hook_form_FORM_ID_alter(&$form, &$form_state, $form_id) {
// Modification for the form with the given form ID goes here. For example, if
// FORM_ID is "user_register_form" this code would run only on the user
// registration form.
@@ -1354,6 +1357,43 @@ function hook_form_FORM_ID_alter(&$form, &$form_state) {
}
/**
+ * Provide a form-specific alteration for shared forms.
+ *
+ * Modules can implement hook_form_BASE_FORM_ID_alter() to modify a specific
+ * form belonging to multiple form_ids, rather than implementing
+ * hook_form_alter() and checking for conditions that would identify the
+ * shared form constructor.
+ *
+ * Examples for such forms are node_form() or comment_form().
+ *
+ * Note that this hook fires after hook_form_FORM_ID_alter() and before
+ * hook_form_alter().
+ *
+ * @param $form
+ * Nested array of form elements that comprise the form.
+ * @param $form_state
+ * A keyed array containing the current state of the form.
+ * @param $form_id
+ * String representing the name of the form itself. Typically this is the
+ * name of the function that generated the form.
+ *
+ * @see hook_form_FORM_ID_alter()
+ * @see drupal_prepare_form()
+ */
+function hook_form_BASE_FORM_ID_alter(&$form, &$form_state, $form_id) {
+ // Modification for the form with the given BASE_FORM_ID goes here. For
+ // example, if BASE_FORM_ID is "node_form", this code would run on every
+ // node form, regardless of node type.
+
+ // Add a checkbox to the node form about agreeing to terms of use.
+ $form['terms_of_use'] = array(
+ '#type' => 'checkbox',
+ '#title' => t("I agree with the website's terms and conditions."),
+ '#required' => TRUE,
+ );
+}
+
+/**
* Map form_ids to form builder functions.
*
* By default, when drupal_get_form() is called, the system will look for a