Skip to content

API References and Resources

Official Drupal Documentation

Primary Form API: - Form API Overview - Form API Workflow - Form Render Elements - Conditional Form Fields

AJAX: - AJAX Forms - AJAX API Concepts

Configuration: - #config_target Documentation - QED42: #config_target Tutorial

Security: - Drupal Security Best Practices 2026 - CSRF Prevention

Batch API: - Batch API Overview - Batch Processing Introduction

Core Code References

Interfaces: - /web/core/lib/Drupal/Core/Form/FormInterface.php - Core contract - /web/core/lib/Drupal/Core/Form/FormStateInterface.php - State management (1160+ lines) - /web/core/lib/Drupal/Core/Form/FormBuilderInterface.php - Builder service

Base Classes: - /web/core/lib/Drupal/Core/Form/FormBase.php - Standard forms - /web/core/lib/Drupal/Core/Form/ConfigFormBase.php - Configuration forms - /web/core/lib/Drupal/Core/Form/ConfirmFormBase.php - Confirmation dialogs

Services: - /web/core/lib/Drupal/Core/Form/FormBuilder.php - Building engine - /web/core/lib/Drupal/Core/Form/FormValidator.php - Validation orchestration - /web/core/lib/Drupal/Core/Form/FormSubmitter.php - Submission handling

API Documentation: - /web/core/lib/Drupal/Core/Form/form.api.php - Hooks and callbacks

Core Examples: - /web/core/modules/user/src/Form/UserLoginForm.php - Login form - /web/core/modules/dblog/src/Form/DblogClearLogConfirmForm.php - Confirm form - /web/core/modules/system/tests/modules/ajax_forms_test/ - AJAX examples

Elements: - /web/core/lib/Drupal/Core/Render/Element/*.php - All element types

AJAX System: - /web/core/lib/Drupal/Core/Ajax/*.php - AJAX commands - /web/core/lib/Drupal/Core/Form/FormAjaxResponseBuilder.php - Response builder

Community Resources

Drupal at your Fingertips: - Forms Chapter - Batch and Queue

Tutorials: - Form API Complete Guide - Multi-step Forms - Adding Form Elements

Performance: - Performance Optimization 2025 - Performance Best Practices

Contributed Modules

Useful Modules: - Conditional Fields - Code-free #states - Webform - Advanced form building - Multistep Form Framework

API Documentation Sites

Drupal API: - Drupal 11.x API - Form and render elements - Best practices

  • Entity API Guide (for entity forms)
  • Configuration API Guide (for config management)
  • AJAX API Guide (for advanced AJAX)
  • Security Best Practices Guide
  • Cache API Guide
  • Typed Data Guide (for schema constraints)

See Also