Hi,
In a template, I would like to be able to check if a input for an attachement/file is empty or not.
i.e., if I have an input tag
{% input custom.foo.bar as:file%}
I want to check if a file has been provided or not, in order to be able to adjust the content of the template accordingly.
Something like
{% if custom.foo.bar == emtpy %}No file has been uploaded {% endif %}
does not work: with as:file-inputs, custom.foo.bar is always empty (although this does work for other input-types as:currency, as:text,…)
Is there another way to check an as:file-input for emptyness, or is such a thing not possible at the moment?
Thanks in advance!
Hello @robin.bailleul,
Could you please try adding .document
in your if-statement:
For example:
{% input custom.foo.bar as:file %}
{% if custom.foo.bar.document == emtpy %}No file has been uploaded {% endif %}
Please let us know if the problem is not solved.
Kind regards,
Mathias
1 Like
Hi @Mathias,
Adding .document did indeed allow me to check whether a as:file input was provided or not.
However, testing for empty always returns false, while testing for blank yields the expected behaviour:
{% input custom.foo.bar as document
{% if custom.foo.bar.document == blank %} No file has been provided
{% else %} A file has been provided {% endif %}
My problem is hereby solved
Thanks!
Kind regards,
Robin