Score:0

Get a term name with twig_tweak drupal_field using a dynamic value

cl flag

I'm using Webform in D9 and have a multipage form. In step 2 of the form, I need to show the taxonomy term that was selected in step 1.

I've defined the field that will display it as a computed twig field.

If I simply use

{{ data.my_field }}

I get back the tid.

If I instead put

{{ drupal_field('name', 'taxonomy_term', <tid> }}

I receive the desired text. However, I need the tid to come from the step 1 variable and not be a static string.

When I try

{{ drupal_field('name', 'taxonomy_term', data.my_field }} 

I receive the error

Argument 3 passed to Twig Tweak Extension::drupal Field() must be of the type string, null given

which I then receive no matter what I try until I delete the field and re-add it. Is there any way in Webform (as opposed to in code) to do the equivalent of:

{% set tid = data.my_field %}
{{ drupal.field('name', 'taxonomy_term', tid) }}
au flag
Try to inspect the data variable to figure out where the tid is. `{{ dd(data) }}`
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.