Form generation

  1. 7.x drupal-7.x/includes/form.inc form_api
  2. 6.x drupal-6.x/includes/form.inc form_api

Functions to enable the processing and display of HTML forms.

Drupal uses these functions to achieve consistency in its form processing and presentation, while simplifying code and reducing the amount of HTML that must be explicitly generated by modules.

The drupal_get_form() function handles retrieving, processing, and displaying a rendered HTML form for modules automatically. For example:

// Display the user registration form.
$output = drupal_get_form('user_register');

Forms can also be built and submitted programmatically without any user input using the drupal_execute() function.

For information on the format of the structured arrays used to define forms, and more detailed explanations of the Form API workflow, see the reference and the Form API guide.

File

drupal-6.x/includes/form.inc, line 22

Functions

Namesort descending Location Description
date_validate drupal-6.x/includes/form.inc Validates the date type to stop dates like February 30, 2006.
drupal_execute drupal-6.x/includes/form.inc Retrieves, populates, and processes a form.
drupal_get_form drupal-6.x/includes/form.inc Retrieves a form from a constructor function, or from the cache if the form was built in a previous page-load. The form is then passed on for processing, after and rendered for display if necessary.
drupal_prepare_form drupal-6.x/includes/form.inc Prepares a structured form array by adding required elements, executing any hook_form_alter functions, and optionally inserting a validation token to prevent tampering.
drupal_process_form drupal-6.x/includes/form.inc This function is the heart of form API. The form gets built, validated and in appropriate cases, submitted.
drupal_rebuild_form drupal-6.x/includes/form.inc Retrieves a form, caches it and processes it with an empty $_POST.
drupal_redirect_form drupal-6.x/includes/form.inc Redirect the user to a URL after a form has been processed.
drupal_render_form drupal-6.x/includes/form.inc Renders a structured form array into themed HTML.
drupal_retrieve_form drupal-6.x/includes/form.inc Retrieves the structured array that defines a given form.
drupal_validate_form drupal-6.x/includes/form.inc Validates user-submitted form data from the $form_state using the validate functions defined in a structured form array.
expand_checkboxes drupal-6.x/includes/form.inc
expand_date drupal-6.x/includes/form.inc Roll out a single date element.
expand_password_confirm drupal-6.x/includes/form.inc Expand a password_confirm field into two text boxes.
expand_radios drupal-6.x/includes/form.inc Roll out a single radios element to a list of radios, using the options array as index.
form_builder drupal-6.x/includes/form.inc Walk through the structured form array, adding any required properties to each element and mapping the incoming $_POST data to the proper elements.
form_clean_id drupal-6.x/includes/form.inc Prepare an HTML ID attribute string for a form item.
form_error drupal-6.x/includes/form.inc Flag an element as having an error.
form_execute_handlers drupal-6.x/includes/form.inc A helper function used to execute custom validation and submission handlers for a given form. Button-specific handlers are checked first. If none exist, the function falls back to form-level handlers.
form_expand_ahah drupal-6.x/includes/form.inc Add AHAH information about a form element to the page to communicate with javascript. If #ahah[path] is set on an element, this additional javascript is added to the page header to attach the AHAH behaviors. See ahah.js for more information.
form_get_cache drupal-6.x/includes/form.inc Fetch a form from cache.
form_get_error drupal-6.x/includes/form.inc Return the error message filed against the form with the specified name.
form_get_errors drupal-6.x/includes/form.inc Return an associative array of all errors.
form_get_options drupal-6.x/includes/form.inc Traverses a select element's #option array looking for any values that hold the given key. Returns an array of indexes that match.
form_options_flatten drupal-6.x/includes/form.inc
form_select_options drupal-6.x/includes/form.inc
form_set_cache drupal-6.x/includes/form.inc Store a form in the cache.
form_set_error drupal-6.x/includes/form.inc File an error against a form element.
form_set_value drupal-6.x/includes/form.inc Change submitted form values during the form processing cycle.
form_type_checkboxes_value drupal-6.x/includes/form.inc Helper function to determine the value for a checkboxes form element.
form_type_checkbox_value drupal-6.x/includes/form.inc Helper function to determine the value for a checkbox form element.
form_type_image_button_value drupal-6.x/includes/form.inc Helper function to determine the value for an image button form element.
form_type_password_confirm_value drupal-6.x/includes/form.inc Helper function to determine the value for a password_confirm form element.
form_type_select_value drupal-6.x/includes/form.inc Helper function to determine the value for a select form element.
form_type_textfield_value drupal-6.x/includes/form.inc Helper function to determine the value for a textfield form element.
form_type_token_value drupal-6.x/includes/form.inc Helper function to determine the value for form's token value.
map_month drupal-6.x/includes/form.inc Helper function for usage with drupal_map_assoc to display month names.
password_confirm_validate drupal-6.x/includes/form.inc Validate password_confirm element.
process_weight drupal-6.x/includes/form.inc Expand weight elements into selects.
theme_button drupal-6.x/includes/form.inc Theme a form button.
theme_checkbox drupal-6.x/includes/form.inc Format a checkbox.
theme_checkboxes drupal-6.x/includes/form.inc Format a set of checkboxes.
theme_date drupal-6.x/includes/form.inc Format a date selection element.
theme_fieldset drupal-6.x/includes/form.inc Format a group of form items.
theme_file drupal-6.x/includes/form.inc Format a file upload field.
theme_form drupal-6.x/includes/form.inc Format a form.
theme_form_element drupal-6.x/includes/form.inc Return a themed form element.
theme_hidden drupal-6.x/includes/form.inc Format a hidden form field.
theme_image_button drupal-6.x/includes/form.inc Theme a form image button.
theme_item drupal-6.x/includes/form.inc Format a form item.
theme_markup drupal-6.x/includes/form.inc
theme_password drupal-6.x/includes/form.inc Format a password field.
theme_password_confirm drupal-6.x/includes/form.inc Format a password_confirm item.
theme_radio drupal-6.x/includes/form.inc Format a radio button.
theme_radios drupal-6.x/includes/form.inc Format a set of radio buttons.
theme_select drupal-6.x/includes/form.inc Format a dropdown menu or scrolling selection box.
theme_submit drupal-6.x/includes/form.inc Theme a form submit button.
theme_textarea drupal-6.x/includes/form.inc Format a textarea.
theme_textfield drupal-6.x/includes/form.inc Format a textfield.
theme_token drupal-6.x/includes/form.inc Format a form token.
weight_value drupal-6.x/includes/form.inc If no default value is set for weight select boxes, use 0.
_element_info drupal-6.x/includes/form.inc Retrieve the default properties for the defined element type.
_form_builder_handle_input_element drupal-6.x/includes/form.inc Populate the #value and #name properties of input elements so they can be processed and rendered. Also, execute any #process handlers attached to a specific element.
_form_builder_ie_cleanup drupal-6.x/includes/form.inc In IE, if only one submit button is present, AND the enter key is used to submit the form, no form value is sent for it and our normal button detection code will never detect a match. We call this function after all other button-detection is complete…
_form_button_was_clicked drupal-6.x/includes/form.inc Helper function to handle the sometimes-convoluted logic of button click detection.
_form_set_class drupal-6.x/includes/form.inc Sets a form element's class attribute.
_form_set_value drupal-6.x/includes/form.inc Helper function for form_set_value().
_form_validate drupal-6.x/includes/form.inc Performs validation on form elements. First ensures required fields are completed, #maxlength is not exceeded, and selected options were in the list of options given to the user. Then calls user-defined validators.