Creating Forms with the Form API
This chapter will cover the usage of the Form API, which is used to create forms in Drupal without writing any HTML! This chapter will walk you through creating a form to manage a custom piece of configuration with validation. You will also learn how to implement conditional form fields using the states
property to control whether an element is hidden, visible, required, or more. We will also demonstrate how AJAX can be implemented in Drupal forms to provide dynamic form elements. Finally, you will learn how to alter other forms in Drupal to customize their application.
In this chapter, we will go through the following recipes:
- Creating a custom form and saving configuration changes
- Validating form data
- Specifying conditional form elements
- Using AJAX in a Drupal form
- Customizing existing forms in Drupal