How to add custom suggestions from the form element array?

Created on 13 May 2025, 28 days ago

Problem/Motivation

I read all the documentation here
https://www.drupal.org/docs/contributed-modules/formdazzle/form-elements
https://www.drupal.org/docs/contributed-modules/formdazzle/form-and-form...
https://www.drupal.org/docs/contributed-modules/formdazzle/miscellaneous...

But for me it's still unclear how to add a new custom theme suggestion to the form element, could you please describe this?

For example, I have two fieldsets like this:

$form['my_fieldset_1'] = [
  '#type' => 'fieldset',
  '#title' => 'My fieldset 1',
];
$form['my_fieldset_2'] = [
  '#type' => 'fieldset',
  '#title' => 'My fieldset 2',
];

and want to use a single Twig template for both of them, named form-element--my-fieldset.html.twig.

But it's unclear how to define this template to make it available in the suggestions?
I tried both options mentioned in the documentation:

  '#theme' => 'my_fieldset',

and

  '#theme_wrappers' => ['my_fieldset'],

but both of them don't work.

Could you please provide a working implementation? Thanks!

💬 Support request
Status

Active

Version

4.0

Component

Documentation

Created by

🇦🇲Armenia murz Yerevan, Armenia

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024