Form generation in Drupal 5
Same name and namespace in other branches
- 4 includes/form.inc \form
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 quickstart guide.
File
- includes/
form.inc, line 3
Functions
Name | Location | Description |
---|---|---|
checkboxes_value |
includes/ |
Helper function to load value from default value for checkboxes. |
date_validate |
includes/ |
Validates the date type to stop dates like February 30, 2006. |
drupal_execute |
includes/ |
Retrieves a form using a form_id, populates it with $form_values, processes it, and returns any validation errors encountered. This function is the programmatic counterpart to drupal_get_form(). |
drupal_get_form |
includes/ |
Retrieves a form from a builder function, passes it on for processing, and renders the form or redirects to its destination as appropriate. In multi-step form scenarios, it handles properly processing the values using the previous step's form… |
drupal_prepare_form |
includes/ |
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 |
includes/ |
This function is the heart of form API. The form gets built, validated and in appropriate cases, submitted. |
drupal_redirect_form |
includes/ |
Redirect the user to a URL after a form has been processed. |
drupal_render_form |
includes/ |
Renders a structured form array into themed HTML. |
drupal_retrieve_form |
includes/ |
Retrieves the structured array that defines a given form. |
drupal_submit_form |
includes/ |
Processes user-submitted form data from a global variable using the submit functions defined in a structured form array. |
drupal_validate_form |
includes/ |
Validates user-submitted form data from a global variable using the validate functions defined in a structured form array. |
expand_checkboxes |
includes/ |
|
expand_date |
includes/ |
Roll out a single date element. |
expand_password_confirm |
includes/ |
Expand a password_confirm field into two text boxes. |
expand_radios |
includes/ |
Roll out a single radios element to a list of radios, using the options array as index. |
form_builder |
includes/ |
Adds some required properties to each form element, which are used internally in the form API. This function also automatically assigns the value property from the $edit array, provided the element doesn't already have an assigned value. |
form_clean_id |
includes/ |
Remove invalid characters from an HTML ID attribute string. |
form_error |
includes/ |
Flag an element as having an error. |
form_get_error |
includes/ |
Return the error message filed against the form with the specified name. |
form_get_errors |
includes/ |
Return an associative array of all errors. |
form_get_options |
includes/ |
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 |
includes/ |
|
form_select_options |
includes/ |
|
form_set_error |
includes/ |
File an error against a form element. If the name of the element is edit[foo][bar] then you may pass either foo or foo][bar as $name foo will set an error for all its children. |
form_set_value |
includes/ |
Use this function to make changes to form values in the form validate phase, so they will be available in the submit phase in $form_values. |
map_month |
includes/ |
Helper function for usage with drupal_map_assoc to display month names. |
password_confirm_validate |
includes/ |
Validate password_confirm element. |
process_weight |
includes/ |
Expand weight elements into selects. |
theme_button |
includes/ |
|
theme_checkbox |
includes/ |
Format a checkbox. |
theme_checkboxes |
includes/ |
Format a set of checkboxes. |
theme_date |
includes/ |
Format a date selection element. |
theme_fieldset |
includes/ |
Format a group of form items. |
theme_file |
includes/ |
Format a file upload field. |
theme_form |
includes/ |
Format a form. |
theme_form_element |
includes/ |
Return a themed form element. |
theme_hidden |
includes/ |
Format a hidden form field. |
theme_item |
includes/ |
Format a form item. |
theme_markup |
includes/ |
Format HTML markup for use in forms. |
theme_password |
includes/ |
Format a password field. |
theme_password_confirm |
includes/ |
Format a password_confirm item. |
theme_radio |
includes/ |
Format a radio button. |
theme_radios |
includes/ |
Format a set of radio buttons. |
theme_select |
includes/ |
Format a dropdown menu or scrolling selection box. |
theme_submit |
includes/ |
|
theme_textarea |
includes/ |
Format a textarea. |
theme_textfield |
includes/ |
Format a textfield. |
theme_token |
includes/ |
|
weight_value |
includes/ |
If no default value is set for weight select boxes, use 0. |
_drupal_clean_form_sessions |
includes/ |
Remove form information that's at least a day old from the $_SESSION['form'] array. |
_element_info |
includes/ |
Retrieve the default properties for the defined element type. |
_form_set_class |
includes/ |
Sets a form element's class attribute. |
_form_set_value |
includes/ |
Helper function for form_set_value(). |
_form_validate |
includes/ |
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. |