0

I only want to add a class to the inside the fieldset from fieldset.html.twig. It's a bit overkill to extend the template for just to add a class.

How can I achieve this with a preprocess function?

function mytheme_preprocess_fieldset(&$variables) {
// $variables['children']['attributes']['class'][] = 'mb-4';
}
1
  • Did you check the content of $variables['children']? It might be already rendered, in which case you are too late and need to find the preprocess hook of the template containing the div which was rendered earlier.
    – 4uk4
    Commented Jun 5, 2020 at 14:40

1 Answer 1

1

Under a fieldsets 'Advanced' settings tab, you can add custom attributes to the fieldset.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.