Skip to main content

Drupal 8/9 - How to add Twig Template Suggestions for fieldset Elements

This is  how you use the hook suggestions function (hook_theme_suggestions_fieldset_alter()) for fieldset  elements to add Twig Template Suggestions in drupal 8-9.

/**
 * @param array $suggestions
 * @param array $variables
 * @param $hook
 */
function THEMENAME_theme_suggestions_fieldset_alter(array &$suggestions, array $variables, $hook)
{
    if (isset($variables['element']['#id'])) {
        $id = str_replace("-", "_", $variables['element']['#id']);
        $suggestions[] = $hook . '__' . $id;
    }
}
best practices

Latest Articles

Controlling ckeditor styling options with hook_editor_js_settings_alter admin_pixelthi… Thu, 05/16/2024 - 10:49 Controlling ckeditor styling options with hook_editor_js_settings_alter

Controlling ckeditor styling options with hook_editor_js_settings_alter

php hook hook_editor_js_settings_alter hook_field_widget_single_[WIDGET_TYPE]_form_alter
#1273 - Unknown collation: 'utf8mb4_0900_ai_ci' admin_pixelthi… Tue, 06/23/2020 - 13:21 #1273 - Unknown collation: 'utf8mb4_0900_ai_ci'

#1273 - Unknown collation: 'utf8mb4_0900_ai_ci'

utf8mb4
How to remove a primary tab from the admin menu in drupal 10 admin_pixelthi… Wed, 03/27/2024 - 17:39 How to remove a primary tab from the admin menu in drupal 10

How to remove a primary tab from the admin menu in drupal 10

hook