0

I have a webform with a Document File field. In my twig email template, I want to test if that field is empty. For text area fields for example, this syntax works :

{% if webform_token('[webform_submission:values:question_text_area:value]', webform_submission) %} <br> <table> <tr> <th>Questions</th> </tr> <tr> <td>{{ webform_token('[webform_submission:values:question_text_area:value]', webform_submission) }}</td> </tr> </table> {% endif %}

But for a Document File field, the same syntax does not work, meaning that if no file is uploaded, that part of my template is still printed.

I tried

{% if webform_token('[webform_submission:values:join_a_file:value]', webform_submission) %}

or

{% if webform_token('[webform_submission:values:join_a_file:value]', webform_submission) is not null %}

or

{% if webform_token('[webform_submission:values:join_a_file]', webform_submission) is not null %}

and none of them work.

Does anybody know the proper syntax for what I'm trying to do? Thanks!

1 Answer 1

2

The solution is to do this

{% if webform_token('[webform_submission:values:file:clear]', webform_submission) %} FILE UPLOADED {% else %} NO FILE UPLOADED {% endif %}

Solution given first here : https://www.drupal.org/project/webform/issues/2969437

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.