drupal-forms-api

Build and manage Drupal forms with validation, submission, and AJAX callbacks.

1|Updated Mar 11, 2026
One-click install
npx skills add https://github.com/proofoftom/drupal-skills --skill drupal-forms-api
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: drupal-forms-api
Source: https://github.com/proofoftom/drupal-skills/tree/main/skills/drupal-forms-api
Command: npx skills add https://github.com/proofoftom/drupal-skills --skill drupal-forms-api

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill streamlines the creation, validation, and submission of forms within Drupal, addressing the complexity of handling user input and configuration settings.

Core Features & Use Cases

  • Form Lifecycle Management: Implement buildForm, validateForm, and submitForm for custom forms.
  • Configuration Forms: Utilize ConfigFormBase for managing module settings with schema validation.
  • Confirmation Forms: Employ ConfirmFormBase for destructive actions with clear user confirmation.
  • Form Altering: Modify existing forms using hook_form_alter and hook_form_FORM_ID_alter.
  • AJAX Forms: Implement dynamic form elements with server-side callbacks for enhanced user experience.
  • Use Case: Create an administrative settings page for a custom module, including input validation and saving configuration to Drupal's config system.

Quick Start

Use the drupal-forms-api skill to create a new Drupal form with a textfield and a submit button.

Frequently Asked Questions about drupal-forms-api

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build a Drupal form with validation and submission?

Build a Drupal form by implementing the `buildForm`, `validateForm`, and `submitForm` methods to manage the form lifecycle. This handles user input collection, data validation, and submission processing within the Drupal Form API.

How do I create an administrative settings page for a custom Drupal module?

Create an administrative settings page by extending `ConfigFormBase` to manage module settings. This allows you to implement input validation and save configuration data directly to Drupal's configuration system with schema validation.

What is the best way to add confirmation dialogs for destructive actions in Drupal?

The best way to add confirmation dialogs is by employing `ConfirmFormBase` for destructive actions. This provides a clear user confirmation step before executing irreversible operations within the Drupal Form API.

Can I modify existing Drupal forms using form alter hooks?

Yes, you can modify existing Drupal forms dynamically using `hook_form_alter` and `hook_form_FORM_ID_alter`. These hooks allow you to alter the structure, elements, or behavior of any form before rendering.

How do I implement dynamic form elements with AJAX in Drupal?

Implement dynamic form elements by using AJAX callbacks within the Drupal Form API. This technique triggers server-side processing to update or inject form elements dynamically without requiring a full page reload.

Does this Drupal form building approach support Drupal 10 and 11?

Yes, this form building approach supports Drupal 10 and 11 compatibility. It provides guidance on defining routing definitions for forms and follows best practices to ensure your forms work correctly across modern Drupal versions.