I'm attempting to query for all assets associated with a specific form submission like this, where 'submission' has been set based on a URL parameter:
{% for field in submission.fieldMetadata %}
{% if field.type == "file" %}
{% set assetId = attribute(submission, field.handle) %}
{% set assets = craft.assets.id(assetId).all() %}
{% for asset in assets %}
{% if asset %}
{% if asset.kind == "image" %}
<img src='{{ asset.url }}'>
{% endif %}
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
The above code returns all site assets rather than just the assets associated with the submission. All other fields associated with the submission are returned correctly. Is this a bug or is my template incorrect?