Can a Computed Twig refrence another Computed Twig?

Created on 1 March 2018, over 6 years ago
Updated 25 January 2023, almost 2 years ago

Simple question here. Can one Computed Twig element reference another Computed Twig element and if so how is that coded? The standard Webform Token reference {{ webform_token('[webform_submission:values:element_value]', webform_submission) }} doesn't work AFAIK, it simply outputs this as the result: [webform_submission:values:element_value].

πŸ’¬ Support request
Status

Fixed

Version

5.0

Component

User interface

Created by

πŸ‡ΊπŸ‡ΈUnited States nodecode

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΈπŸ‡ΎSyria alsammanKhaled

    Hey, I am facing an issue with referring computed twig elements into one.
    I have 3 computed twig elements that i want to get their total using computed twig.
    The moment i try to follow

    {% set test1= webform_token('[webform_submission:values:test1]', webform_submission) %}
    {% set test2 = webform_token('[webform_submission:values:test2]', webform_submission) %}
    {% set test3 = webform_token('[webform_submission:values:test3]', webform_submission) %}
        {{ test1 + test2 }}

    I get the following error "Wrong operant string + string".
    Another main issue is that I can't edit the 'total' computed twig anymore. even from the YAML tab. I will have to delete the element and try again differently.

    I also tried
    {{data.test1 + data.test2 + data.test3 }}
    Also

    {% set total= total + webform_token('[webform_submission:values:test1]', webform_submission) %}
    {% set total= total + webform_token('[webform_submission:values:test2]', webform_submission) %}
    {% set total= total + webform_token('[webform_submission:values:test3]', webform_submission) %}
    {{total}}
    

    I get the same issue as wrong operant. if i am using the "Test" tab i can see that the form is actually working properly. but the moment i go to "Result" or "View". I get the errors.

    Any help would be much appreciate it. If there is more info required i can provide.

    I am using Drupal 9.5

Production build 0.71.5 2024