Hello,
I have a form with a file
field. The form values are then sent in a e-mail.
The file value is shown like this:
Your file: {"\/en\/path\/form\/file.pdf":{"name":"file.pdf","type":"application\/ pdf","size":63842,"file":"user\/pages\/path\/form\/file.pdf","route":"\/en\/path\/form\/file.pdf"}}
I would like it to appear like this instead (showing only the file
sub-value):
Your file: (File) user/pages/path/form/file.pdf
So I edited data.html.twig
:
{% for field in form.fields %}
{% block field %}
{% if field.name!='g-recaptcha-response' %}
<div>{% block field_label %}<strong>{{ field.label }}</strong>{% endblock %}: {% block field_value %}
{% if field.type=='file' %}
(File) {{ string(form.value(field.name).file|e) }}
{% else %}
{{ string(form.value(field.name)|e) }}
{% endif %}
{% endblock %}</div>
{% endif %}
{% endblock %}
{% endfor %}
{{ string(form.value(field.name).file|e) }}
turns out to be empty; what would be the proper syntax to get this value? Eventually, I would like to make a link:
(File) <a href='http://site.org/{{ string(form.value(field.name).file|e) }}'>{{ string(form.value(field.name).name|e) }}</a>
Thank you