I have a block, which renders out a form using code that looks like this:
{{ attribute(form.facets, 'filter_' ~ filter.name) }}
I’d like to amend the markup and CSS classes for the various elements that are output, including fieldset, input, label etc. I appreciate that I can override the template files for fieldset for example, by creating a fieldset.html.twig file in my theme, but I don’t want to change the markup for every fieldset element. I only want to apply my custom templates to form elements which are rendered out from a specific block.
I know that I can use a ‘suggestion’ (mytheme_theme_suggestions_alter) to alter the template for any element, but I can’t see a way of determining if an ‘input’ for example, is an input within my block, or some other block on the site. Does anyone know how I’d identify this?
Sponsored by SupremePR