Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: Drupal 11.4.6 Update released for Drupal core (11.4.6)! Release: Drupal 10.6.16 Update released for Drupal core (10.6.16)! Release: PhotoSwipe - Responsive JavaScript Modal Image Gallery 5.0.10 Minor update available for module photoswipe (5.0.10). Release: Twig Tweak 4.0.0-alpha5 New alpha version released for module twig_tweak (4.0.0-alpha5). Release: Media PDF Thumbnail 6.1.10 Minor update available for module media_pdf_thumbnail (6.1.10). Release: UI Patterns (SDC in Drupal UI) 2.0.21 Minor update available for module ui_patterns (2.0.21). Release: MTCaptcha 11.1.0 Minor update available for module mtcaptcha (11.1.0). Release: Drupal LMS 1.2.2 Minor update available for module lms (1.2.2). Module Revived: Media PDF Thumbnail 7.0.1 Module media_pdf_thumbnail updated after 15 months of inactivity (7.0.1). Usage Milestone: Menu Condition Module menu_condition crossed 1,000 active installs.

This module provides stable Twig template suggestions for individual form elements, allowing themes to override specific fields or buttons predictably. It generates cache-safe, form-scoped template names like `input--submit--form--contact--submit.html.twig`. This is particularly useful for site builders and themers who need to customize forms where HTML IDs might change, such as with Webform or Views.

Form Twig Template Suggester gives themes stable Twig suggestions for individual form controls (text fields, selects, buttons, and more). That means you can override one submit button or one field in a specific form without fighting Drupal’s changing HTML IDs or changing how the form submits.

It is aimed at site builders and themers who need predictable template names like input--submit--form--contact--submit.html.twig.

Features

  • Automatically adds form-scoped theme suggestions for common form elements: input, select, textarea, radios, checkboxes, button, form_element, and form_element_label.
  • Uses cache-safe, namespaced render-array metadata only (#twigsuggest_form_*). It does not change core #name or #form_id on form children, so Form API and AJAX behaviour stay intact.
  • Stable “source” identity per form family:
    • Webform — webform machine name (for example contact), not the long per-entity submission form id
    • Views exposed forms — cleaned Views form id, with consistent naming for action buttons
    • Other forms — PHP form id
  • Extensible: other modules can add tagged resolvers for custom form types.
  • AJAX / FormCache friendly (including multi-step Webforms).
  • Works alongside contrib twigsuggest (HTML-id style suggestions); this module focuses on form-scoped names.

When to use it: you need theme templates keyed by form + control, especially where HTML IDs change across pages or AJAX rebuilds (contact forms, search forms, multi-step forms, and similar).

Post-Installation

  1. Enable Form Twig Template Suggester (twigsuggest_form).
  2. Clear caches.
  3. Turn on Twig debugging (or inspect suggestions another way) and open a page with a form. Look for suggestions such as input--submit--form--{source}--{name}.html.twig or form-element--form--{source}.html.twig.
  4. Add matching templates in your theme, for example input--submit--form--user_form--op.html.twig or input--textfield--form--contact--email.html.twig.

Behaviour applies automatically to forms. If Webform or Views are installed, source IDs for those forms become more stable and theme-friendly.

Additional Requirements

  • Drupal core ^11.2
  • PHP 8.3+

No required contrib modules, libraries, or external APIs beyond Drupal core.

  • Webform — machine-name based suggestions and better support for multi-step / composite forms
  • Views (in core on modern Drupal) — exposed-form source resolution
  • twigsuggest — complementary ID-based suggestions; safe to use together

Similar projects

  • twigsuggest — focuses on suggestions from HTML IDs / attributes. Form Twig Template Suggester instead stamps form identity in a cache-safe way and builds form-scoped suggestions without writing data-* attributes or altering Form API #name / #form_id.
  • Themable Forms — classic approach of copying #form_id onto children for form_element suggestions. This module uses namespaced properties only, covers more control types, and adds Webform/Views-aware source IDs.

Supporting this Module

Development is supported by Big Blue Door.

Community Documentation

Note: This project is not (yet) covered by Drupal’s security advisory policy. Use accordingly until it opts into the security team process.

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
4
Tracked since
Jul 2026
Latest release
1 month ago
Releases (12 mo)
4 ▲ from 0
Maintenance
Active

Release Timeline

Releases

Version Type Core Release date
1.0.0-beta3 Pre-release 11 Jul 21, 2026
1.0.0-beta2 Pre-release 11 Jul 21, 2026
1.0.0-beta1 Pre-release 11 Jul 21, 2026
1.0.x-dev Dev 11 Jul 21, 2026