Display asset (name) in a submission overview #1688
-
When trying this guide, is it possible to display anything that was uploaded to an asset/upload field? It's worth noting that all assets are uploaded to a "protected" directory, one that does not have a public URL. This can not change. I tried something like this:
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Hi @FrDH, Can you try something like this instead? {% set assetId = form.get('myUploadField').value %}
<p>Here's the uploaded file(s):</p>
<ul>
{% for asset in craft.assets.id(assetId).all %}
<li>{{ asset.url }}</li>
{% endfor %}
</ul> Also, are you entering this into a Twig-enabled HTML block in the form builder, or something else? 🙂 |
Beta Was this translation helpful? Give feedback.
-
Thank you for the suggestion, but unfortunately it does not out output anything (other than an empty UL). I changed the upload-directory to one with a public URL, but that didn't help. {% for field in allFields|filter(f => f.valueAsString and f.type in ['file', 'file_drag_and_drop']) %}
<dt>{{ field.label }}</dt>
<dd>
<!-- {{ field.valueAsString }} -->
{% for asset in craft.assets.id(field.valueAsString).all %}
url: {{ asset.url }}<br>
{% endfor %}
</dd>
{% endfor %}
</dl> Note that Thanks for any insights. |
Beta Was this translation helpful? Give feedback.
-
@gustavs-gutmanis Thanks! That works. |
Beta Was this translation helpful? Give feedback.
Hi @FrDH,
You can access the
AssetQuery
directly on theFileUploadField
via::getAssets()
.