Skip to main content

The Form API

  • Chapter
Pro Drupal Development
  • 358 Accesses

Abstract

Drupal 4.7 and later feature an application programming interface (API) for generating, validating, and processing HTML forms. The form API abstracts forms into a nested array of properties and values. The array is then rendered by the form-rendering engine at the appropriate time while a page is being generated. There are several implications of this approach:

  • • Rather than output HTML, we create an array and let the engine generate the HTML.

  • • Since we are dealing with a representation of the form as structured data, we can add, delete, reorder, and change forms. This is especially handy when you want to modify a form created by a different module in a clean and unobtrusive way.

  • • Any form element can be mapped to any theme function.

  • • Additional form validation or processing can be added to any form.

  • • Operations with forms are protected against form injection attacks, where a user modifies a form and then tries to submit it.

  • • The learning curve for using forms is a little steeper!

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 34.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Rights and permissions

Reprints and permissions

Copyright information

© 2007 John K. VanDyk and Matt Westgate

About this chapter

Cite this chapter

(2007). The Form API. In: Pro Drupal Development. Apress. https://doi.org/10.1007/978-1-4302-0190-8_10

Download citation

Publish with us

Policies and ethics