I want to change a theme hook for one field from a custom FieldFormatter. It’s #theme callback is ‘field’ but I want to give the user the option to toggle a setting that changes this to ‘field_raw’, which then uses a Twig template with no markup. I can’t figure out the theme hook.
Twig template:
{%- for item in items %}{{ item.content }}{% endfor -%}
Module hook:
function mymodule_theme($existing, $type, $theme, $path) { return [ 'field_raw' => [ 'items' => NULL, ], ]; }
I am unsure of what to pass here that makes it to the twig template. I can output text in the template so I know it is being hit. What is the right variables to set here so the template receives it?
I also tried:
'render element' => 'element'
'render element' => 'elements'
'render element' => 'children'