Form API

For an interactive, data-driven website such as one built with Drupal, collecting and processing user submitted data will be exceptionally important. Most of this data can be captured using a web based form, i.e. An HTML structure with textfields and widgets for selecting different options.

Getting a form on to a webpage is easy, getting the user's responses is easy too, getting them securely is much, much harder. Drupal provides a standard, easy to use, easy to extend and secure way of adding forms to your Drupal website: Form API or FAPI for short.

This guide describes the different things that you can do using Form API.

See also Form API Reference.

Creating a builder function to generate a form

Form workflow usually follows these stages:

Form API Internal Workflow Illustration

This workflow actually includes some of the nodeapi hooks as well as FAPI workflow to help illustrate the places where form elements can be

Forms API - Modify Form widgets with hook_field_widget_form_alter()

Widgets are the parts that make up forms, like textarea widgets, file upload widgets etc.

Forms API - Modify Forms with hook_form_alter()

Drupal 7 forms that modules create can be changed by other modules and even themes with the help of Drupal FAPI hooks system. See Drupal 7

#tree and #parents

Explain the use of #tree and #parents properties in a form array.

Guide maintainers