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:

<?php

// 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.

Functions

Namesort iconLocationDescription
cart_product_form_submitecommerce-5--4/cart/cart.moduleThe "Add to cart" form with Quantity
checkboxes_valuedrupal-5/includes/form.incHelper function to load value from default value for checkboxes.
date_validatedrupal-5/includes/form.incValidates the date type to stop dates like February 30, 2006.
drupal_executedrupal-5/includes/form.incRetrieves 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_formdrupal-5/includes/form.incRetrieves 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_formdrupal-5/includes/form.incPrepares 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_formdrupal-5/includes/form.incThis function is the heart of form API. The form gets built, validated and in appropriate cases, submitted.
drupal_redirect_formdrupal-5/includes/form.incRedirect the user to a URL after a form has been processed.
drupal_render_formdrupal-5/includes/form.incRenders a structured form array into themed HTML.
drupal_retrieve_formdrupal-5/includes/form.incRetrieves the structured array that defines a given form.
drupal_submit_formdrupal-5/includes/form.incProcesses user-submitted form data from a global variable using the submit functions defined in a structured form array.
drupal_validate_formdrupal-5/includes/form.incValidates user-submitted form data from a global variable using the validate functions defined in a structured form array.
ec_checkout_admin_screen_formecommerce-5--4/ec_checkout/ec_checkout.admin.incForm for determining the order of the checkout screens.
ec_checkout_admin_screen_form_submitecommerce-5--4/ec_checkout/ec_checkout.admin.incForm for determining the order of the checkout screens.
ec_checkout_product_formecommerce-5--4/ec_checkout/ec_checkout.moduleThe "Add to cart" form with Quantity
expand_datedrupal-5/includes/form.incRoll out a single date element.
expand_radiosdrupal-5/includes/form.incRoll out a single radios element to a list of radios, using the options array as index.
form_builderdrupal-5/includes/form.incAdds 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_iddrupal-5/includes/form.incRemove invalid characters from an HTML ID attribute string.
form_errordrupal-5/includes/form.incFlag an element as having an error.
form_get_errordrupal-5/includes/form.incReturn the error message filed against the form with the specified name.
form_get_errorsdrupal-5/includes/form.incReturn an associative array of all errors.
form_get_optionsdrupal-5/includes/form.incTraverses a select element's #option array looking for any values that hold the given key. Returns an array of indexes that match.
form_set_errordrupal-5/includes/form.incFile 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_valuedrupal-5/includes/form.incUse 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.
invoice_delete_confirmecommerce-5--4/invoice/invoice.moduleinvoice_delete_confirm()
invoice_delete_confirm_submitecommerce-5--4/invoice/invoice.moduleinvoice_delete_confirm()
invoice_formecommerce-5--4/invoice/invoice.moduleCreate an invoice form
invoice_form_reviewecommerce-5--4/invoice/invoice.moduleReview an invoice
invoice_form_review_submitecommerce-5--4/invoice/invoice.module
invoice_form_review_validateecommerce-5--4/invoice/invoice.module
invoice_form_submitecommerce-5--4/invoice/invoice.module
invoice_form_validateecommerce-5--4/invoice/invoice.module
invoice_settings_form_submitecommerce-5--4/invoice/invoice.module
map_monthdrupal-5/includes/form.incHelper function for usage with drupal_map_assoc to display month names.
password_confirm_validatedrupal-5/includes/form.incValidate password_confirm element.
process_weightdrupal-5/includes/form.incExpand weight elements into selects.
product_admin_ptypes_delete_submitecommerce-5--4/product/product.admin.incSubmit product_admin_ptypes_delete()
product_admin_ptypes_feature_deleteecommerce-5--4/product/product.admin.incConfirm if the product feature should be deleted
product_admin_ptypes_feature_delete_submitecommerce-5--4/product/product.admin.incConfirm if the product feature should be deleted
product_admin_ptypes_feature_formecommerce-5--4/product/product.admin.incLink product types to features. Path: 'admin/ecsettings/ptypes/.../add_feature
product_admin_ptypes_feature_form_submitecommerce-5--4/product/product.admin.incSubmit for product_admin_ptypes_feature_form()
product_admin_ptypes_feature_list_submitecommerce-5--4/product/product.admin.incSubmit for product_admin_ptypes_feature_list()
product_admin_ptypes_form_submitecommerce-5--4/product/product.admin.incSubmit product_admin_ptypes_form()
product_admin_ptypes_form_validateecommerce-5--4/product/product.admin.incValidate product_admin_ptypes_form()
product_edit_formecommerce-5--4/product/product.module
theme_checkboxdrupal-5/includes/form.incFormat a checkbox.
theme_checkboxesdrupal-5/includes/form.incFormat a set of checkboxes.
theme_datedrupal-5/includes/form.incFormat a date selection element.
theme_fieldsetdrupal-5/includes/form.incFormat a group of form items.
theme_filedrupal-5/includes/form.incFormat a file upload field.
theme_formdrupal-5/includes/form.incFormat a form.
theme_form_elementdrupal-5/includes/form.incReturn a themed form element.
theme_hiddendrupal-5/includes/form.incFormat a hidden form field.
theme_itemdrupal-5/includes/form.incFormat a form item.
theme_passworddrupal-5/includes/form.incFormat a password field. * *
theme_password_confirmdrupal-5/includes/form.incFormat a password_confirm item.
theme_radiodrupal-5/includes/form.incFormat a radio button.
theme_radiosdrupal-5/includes/form.incFormat a set of radio buttons.
theme_selectdrupal-5/includes/form.incFormat a dropdown menu or scrolling selection box.
theme_textareadrupal-5/includes/form.incFormat a textarea.
theme_textfielddrupal-5/includes/form.incFormat a textfield.
weight_valuedrupal-5/includes/form.incIf no default value is set for weight select boxes, use 0.
_address_formecommerce-5--4/address/address.incInsert the address fields to the form.
_coupon_gc_formecommerce-5--4/contrib/coupon/coupon.incGift Certificate form
_drupal_clean_form_sessionsdrupal-5/includes/form.incRemove form information that's at least a day old from the $_SESSION['form'] array.
_element_infodrupal-5/includes/form.incRetrieve the default properties for the defined element type.
_form_set_classdrupal-5/includes/form.incSets a form element's class attribute.
_form_set_valuedrupal-5/includes/form.incHelper function for form_set_value().
_form_validatedrupal-5/includes/form.incPerforms 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.
_invoice_gen_menuecommerce-5--4/invoice/invoice.modulePrivate functions
_invoice_get_from_formecommerce-5--4/invoice/invoice.modulePrivate functions
_invoice_settingsecommerce-5--4/invoice/invoice.admin.incCalled through invoice_settings()
_product_alter_node_type_formecommerce-5--4/product/product.admin.incAdditional settings that are added to the node type form at admin/content/types/*
_product_alter_product_formecommerce-5--4/product/product.admin.incGenerates product form fields to be added into the node form. Called from product_form_alter().
_product_edit_formecommerce-5--4/product/product.admin.inc