<p>Assuming you are on a <a href="https://craftcms.com/knowledge-base/entry-form" rel="nofollow noreferrer">front end entry form</a> editing an entry, there are a few steps to this.</p>
<p>First get all assets a user can choose from:</p>
<pre class="lang-twig prettyprint-override"><code>{% set allImages = myAssetQuery.all() %}
</code></pre>
<p>Next, get the ids of already chosen assets:</p>
<pre class="lang-twig prettyprint-override"><code>{% set alreadyChosenImages = entry.businessStandardImages.ids() %}
</code></pre>
<p>Loop over all images, check the ones already selected:</p>
<pre class="lang-twig prettyprint-override"><code>{% for image in allImages %}
&lt;div&gt;
    &lt;label&gt;{{ image.title }}
        {{ input(
            'checkbox',
            'fields[businessStandardImages][]',
            image.id,
            { checked: image.id in alreadyChosenImages }
        ) }}
    &lt;/label&gt;
&lt;/div&gt;
{% endfor %}
</code></pre>
<p>Altogether:</p>
<pre class="lang-twig prettyprint-override"><code>{# Get all possible assets #}
{% set allImages = myAssetQuery.all() %}

{# Get the currently related asset IDs #}
{% set alreadyChosenImages = entry is defined
    ? entry.businessStandardImages.ids()
    : [] %}

{# Loop over images and check any already selected ones #}
{% for image in allImages %}
&lt;div&gt;
    &lt;label&gt;{{ image.title }}
        {{ input(
            'checkbox',
            'fields[businessStandardImages][]',
            image.id,
            { checked: image.id in alreadyChosenImages }
        ) }}
    &lt;/label&gt;
&lt;/div&gt;
{% endfor %}
</code></pre>
<p>There is also <a href="https://craftcms.com/docs/3.x/assets-fields.html#saving-assets-fields" rel="nofollow noreferrer">a complete example in the documentation</a>.</p>

CC BY-SA 4.0
2021-02-03T10:49:51.117Z
2021-02-03T10:49:51.117Z
Oli
<p>Good afternoon All,</p>
<p>Im trying to setup the ability for users to delete 1 or more of their own images from a multi photo asset field and have got stuck.</p>
<p>This is what is have so far,  I assumed adding a blank value would remove the asset in question</p>
<pre><code>{% set images = myAssetQuery.all() %}

{% for image in images %}
    &lt;span&gt;&lt;img src=&quot;{{ image.getUrl('listingthumb') }}&quot; alt=&quot;{{ image.title }}&quot;&gt;&lt;/span&gt;

    &lt;input type=&quot;checkbox&quot; name=&quot;fields[businessStandardImages][]&quot; value=&quot;&quot; /&gt;

{% endfor %}
</code></pre>
<p>Any help would be greatfully received</p>

<craft3><assets><form><assets-field>
Deleting one or all Assets from a fieldusing a front end form
# Deleting one or all Assets from a fieldusing a front end form

(Asked by: username_0 on 2021-02-01)

Good afternoon All,
Im trying to setup the ability for users to delete 1 or more of their own images from a multi photo asset field and have got stuck.
This is what is have so far,  I assumed adding a blank value would remove the asset in question
{% set images = myAssetQuery.all() %}

{% for image in images %}
    

    

{% endfor %}

Any help would be greatfully received

**Tags:** craft3, assets, form, assets-field

---

## 1 answers

### Answer by username_1 on 2021-02-03. Score: 2 | Accepted answer

Assuming you are on a front end entry form editing an entry, there are a few steps to this.
First get all assets a user can choose from:
{% set allImages = myAssetQuery.all() %}

Next, get the ids of already chosen assets:
{% set alreadyChosenImages = entry.businessStandardImages.ids() %}

Loop over all images, check the ones already selected:
{% for image in allImages %}

    {{ image.title }}
        {{ input(
            'checkbox',
            'fields[businessStandardImages][]',
            image.id,
            { checked: image.id in alreadyChosenImages }
        ) }}
    

{% endfor %}

Altogether:
{# Get all possible assets #}
{% set allImages = myAssetQuery.all() %}

{# Get the currently related asset IDs #}
{% set alreadyChosenImages = entry is defined
    ? entry.businessStandardImages.ids()
    : [] %}

{# Loop over images and check any already selected ones #}
{% for image in allImages %}

    {{ image.title }}
        {{ input(
            'checkbox',
            'fields[businessStandardImages][]',
            image.id,
            { checked: image.id in alreadyChosenImages }
        ) }}
    

{% endfor %}

There is also a complete example in the documentation.


---

