I would like to add a custom twig template for the table of a multiple value form element that is shown on a node edit page.

Let's say we have a simple input textfield that allows entering multiple values. This creates a table with draggable rows and an add more button below the table. I would like to be able to theme that table.

By default this uses the table.html.twig template. If i overwrite the table.html.twig file in my template, this is applied to all tables throughout the page. So I'd like to have a template that is only applied to tables within the multiple value form element, something like table-multiple-value-form.html.twig.

I was thinking about using hook_theme_suggestions_HOOK_alter() to add a template suggestion, but within this function I can not determine whether this table is a child of a multiple value form element or just some other table.

How would I approach this problem?

Thanks a lot for your help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.