In side the top-template (in our case webform.html.twig) we call the child template with an include like this {% include "@atoms/02-text/00-headings/_heading.twig".
Inside the child template function bem() is called: {{ bem(heading_base_class, (heading_modifiers), heading_blockname) }}
Further down in the parent template, after the include, {{attributes}} is rendered. In this case it must print the form attributes like id, class, but also form-specific attributes like method and action.
What happened:
The function bem() in bem.function.php removes/resets the attribute function in the following block of code:
// Remove the attribute from context so it doesn't trickle down to
// includes.
$context['attributes']->removeAttribute($key);
The effect is that {{attributes}} is empty.
If I uncomment above, then bem() prints the attributes of the webform in the _heading.twig. Also not good. But the good part is that the webform itself can print its attributes. (In this example the attribute-list is printed 2 times in the webform and the heading template).
Reproduction repository (if necessary):
Problem description:
How can this problem be avoided?
Suggested solution:
Either that the bem() function resolves this automatically,
or by adding some documentation how the bem() function must be called to avoid this problem.
What you did:
We have a hierarchy of templates.
webform.html.twig
) we call the child template with an include like this{% include "@atoms/02-text/00-headings/_heading.twig"
.bem()
is called:{{ bem(heading_base_class, (heading_modifiers), heading_blockname) }}
{{attributes}}
is rendered. In this case it must print the form attributes likeid
,class
, but also form-specific attributes likemethod
andaction
.What happened: The function
bem()
inbem.function.php
removes/resets the attribute function in the following block of code:The effect is that
{{attributes}}
is empty. If I uncomment above, thenbem()
prints the attributes of the webform in the_heading.twig
. Also not good. But the good part is that the webform itself can print its attributes. (In this example the attribute-list is printed 2 times in the webform and the heading template).Reproduction repository (if necessary):
Problem description: How can this problem be avoided?
Suggested solution: Either that the bem() function resolves this automatically, or by adding some documentation how the bem() function must be called to avoid this problem.