diff --git includes/form.inc includes/form.inc index bd4b8d4..7a40e89 100644 --- includes/form.inc +++ includes/form.inc @@ -89,10 +89,15 @@ * * The $form_state keys are: * - build_info: Do not change; internal information stored by Form API to be - * able to build and rebuild the form: + * able to build and rebuild the form from cache when the original context + * may no longer be available: * - args: A list of arguments used to rebuild the form from cache. - * - files: A list of include files to be loaded to rebuild the form. See - * form_load_include(). + * - files: An optional array defining include files that need to be loaded + * for building the form. See form_load_include(). Each array entry may be + * the path to a file or another array containing values for the parameters + * 'type', 'module' and 'name' as needed by module_load_include(). The files + * listed here are automatically loaded by form_get_cache(). By default the + * current menu router item's 'file' definition is added, if existent. * - 'values': An associative array of values submitted to the form. The * validation functions and submit functions use this array for nearly all * their decision making. (Note that @@ -107,6 +112,8 @@ * see drupal_build_form(). * - 'redirect': a URL that will be used to redirect the form on submission. * See drupal_redirect_form() for complete information. + * - no_redirect: If set to TRUE the form will NOT perform a drupal_goto(), + * even if 'redirect' is set. * - 'storage': $form_state['storage'] is not a special key, and no specific * support is provided for it in the Form API, but by tradition it was * the location where application-specific data was stored for communication @@ -131,6 +138,14 @@ * which may or may not be a button (in the case of AJAX forms.) This is * often used to distinguish between various buttons in a submit handler, * and is also used in AJAX handlers. + * - 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 implementations may either define the 'wrapper_callback' via + * hook_forms() or have to invoke drupal_build_form() (instead of + * drupal_get_form()) on their own in a custom menu callback to prepare + * $form_state accordingly. See drupal_build_form(). * - 'cache': The typical form workflow involves two page requests. During the * first page request, a form is built and returned for the user to fill in. * Then the user fills the form in and submits it, triggering a second page @@ -146,12 +161,28 @@ * it's a classic example of this use case.) Note that the persistence of * $form and $form_state across successive submissions of a multi-step form * happens automatically regardless of the value for 'cache'. + * - no_cache: If set to TRUE the form will NOT be cached, even if 'cache' is + * set. * - 'input': The array of values as they were submitted by the user. These are * raw and unvalidated, so should not be used without a thorough understanding * of security implications. In almost all cases, code should use the data in * the 'values' array exclusively. The most common use of this key is for * multi-step forms that need to clear some of the user input when setting * 'rebuild'. + * - method: The HTTP form method to use for finding the input for this form. + * May be 'post' or 'get'. Defaults to 'post'. Note that 'get' method + * forms do not use form ids so are always considered to be submitted, which + * can have unexpected effects. The 'get' method should only be used on + * forms that do not change data, as that is exclusively the domain of post. + * - always_process: If TRUE and the method is GET, a form_id is not + * necessary. This should only be used on RESTful GET forms that do NOT + * write data, as this could lead to security issues. It is useful so that + * searches do not need to have a form_id in their query arguments to + * trigger the search. + * - must_validate: Ordinarily, a form is only validated once but there are + * 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. */ /** @@ -208,65 +239,9 @@ function drupal_get_form($form_id) { * when the form submission process is complete. Furthermore, it may be used * to store information related to the processed data in the form, which will * persist across page requests when the 'cache' or 'rebuild' flag is set. - * The following parameters may be set in $form_state to affect how the form - * is rendered: - * - build_info: A keyed array of build information that is necessary to - * rebuild the form from cache when the original context may no longer be - * available: - * - args: An array of arguments to pass to the form builder. - * - files: An optional array defining include files that need to be loaded - * for building the form. Each array entry may be the path to a file or - * another array containing values for the parameters 'type', 'module' and - * 'name' as needed by module_load_include(). The files listed here are - * automatically loaded by form_get_cache(). By default the current menu - * router item's 'file' definition is added, if existent. - * - rebuild: Normally, after the entire form processing is completed and - * submit handlers ran, a form is considered to be done and - * drupal_redirect_form() will redirect the user to a new page using a GET - * request (so a browser refresh does not re-submit the form). However, if - * 'rebuild' has been set to TRUE, then a new copy of the form is - * immediately built and sent to the browser; instead of a redirect. This is - * used for multi-step forms, such as wizards and confirmation forms. - * Normally, $form_state['rebuild'] is set by a submit handler, since it is - * usually logic within a submit handler that determines whether a form is - * done or requires another step. However, a validation handler may already - * set $form_state['rebuild'] to cause the form processing to bypass submit - * handlers and rebuild the form instead, even if there are no validation - * errors. - * - input: An array of input that corresponds to $_POST or $_GET, depending - * on the 'method' chosen (see below). - * - method: The HTTP form method to use for finding the input for this form. - * May be 'post' or 'get'. Defaults to 'post'. Note that 'get' method - * forms do not use form ids so are always considered to be submitted, which - * can have unexpected effects. The 'get' method should only be used on - * forms that do not change data, as that is exclusively the domain of post. - * - no_redirect: If set to TRUE the form will NOT perform a drupal_goto(), - * even if 'redirect' is set. - * - cache: If set to TRUE the original, unprocessed form structure will be - * cached, which allows to rebuild the entire form from cache. - * - no_cache: If set to TRUE the form will NOT be cached, even if 'cache' is - * set. - * - always_process: If TRUE and the method is GET, a form_id is not - * necessary. This should only be used on RESTful GET forms that do NOT - * write data, as this could lead to security issues. It is useful so that - * searches do not need to have a form_id in their query arguments to - * trigger the search. - * - must_validate: Ordinarily, a form is only validated once but there are - * 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. - * - temporary: An array holding temporary data accessible during the current - * page request only. It may be used to temporary save any data that doesn't - * need to or shouldn't be cached during the whole form workflow, e.g. data - * that needs to be accessed during the current form build process only. - * - 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 implementations may either define the 'wrapper_callback' via - * hook_forms() or have to invoke drupal_build_form() (instead of - * drupal_get_form()) on their own in a custom menu callback to prepare - * $form_state accordingly. + * The various $form_state keys are enumerated in + * @link form_api Form Generation endlink. + * Further $form_state properties controlling the redirection behavior after * form submission may be found in drupal_redirect_form(). *