<p>Thanks for the assist. Just updated my Craft and all sorted.</p>

CC BY-SA 4.0
2020-07-28T19:46:55.707Z
Fixed in Craft CMS 3.4.30 - as of 7/27/20.
RitterKnight
CC BY-SA 4.0
2020-07-27T08:43:23.787Z
2020-07-27T08:43:23.787Z
Ian Ebden
<p>I've created an entry form with an assets field. All works great, uploading to portfolio/{currentUser.id} directories. On edit forms I only want to list assets uploaded by the <code>currentUser</code> so the <code>.uploader(currentUser)</code> param on the asset query is perfect. BUT... when user uploads assets their <code>id</code> is not being recorded. I can see it listed as NULL in the assets database table. Consequently, the newly uploaded asset won't appear in the existing assets list for the <code>currentUser</code>. Make sense?</p>
<p>So yeah, basically I want front end form asset uploads to record the uploader's <code>id</code>.</p>
<p>Any thoughts much appreciated.</p>
<p>Here's the field in my form...</p>
<pre><code>&lt;form method=&quot;post&quot; accept-charset=&quot;UTF-8&quot; enctype=&quot;multipart/form-data&quot; autocomplete=&quot;on&quot; class=&quot;block&quot; id=&quot;account&quot;&gt;
{{ actionInput('users/save-user') }}
{{ csrfInput() }}
{{ hiddenInput('userId', currentUser.id) }}

{%- set field = craft.app.fields.getFieldByHandle('userPortfolio') %}
{%- if field|length %}
    {# include a hidden input first so Craft knows to update the existing value, if no checkboxes are checked #}
    {{ hiddenInput('fields[userPortfolio]', '') }}
    
    {# get existing assets for this user #}
    {% set possibleAssets = craft.assets()
        .volume('cdn')
        .uploader(currentUser)
        .kind('image')
        .orderBy('filename ASC')
        .withTransforms([
            { width: 100, height: 100 }
        ])
    .all() %}

    {# get the currently related asset IDs #}
    {% set relatedAssetIds = currentUser
        ? currentUser.userPortfolio.ids()
        : [] %}

    &lt;div class=&quot;field mb-6&quot;&gt;
        &lt;label for=&quot;{{ field.id }}&quot; class=&quot;label&quot;&gt;{{ field.name }}{%- if field.instructions %} &lt;span class=&quot;label-hint&quot;&gt;{{ field.instructions }}&lt;/span&gt;{%- endif %}&lt;/label&gt;
        {%- if possibleAssets|length %}
            &lt;p class=&quot;control&quot;&gt;
                &lt;table class=&quot;table is-fullwidth&quot;&gt;
                    &lt;thead&gt;
                        &lt;th class=&quot;is-narrow&quot;&gt;&lt;span class=&quot;is-hidden&quot;&gt;Checkboxes&lt;/span&gt;&lt;/th&gt;
                        &lt;th class=&quot;is-narrow&quot;&gt;Photo&lt;/th&gt;
                        &lt;th&gt;Filename&lt;/th&gt;
                    &lt;/thead&gt;
                    &lt;tfoot&gt;
                        &lt;tr&gt;
                            &lt;td colspan=&quot;3&quot; class=&quot;has-text-grey-light&quot;&gt;Uncheck an image and save the form to hide it on your public portfolio&lt;/td&gt;
                        &lt;/tr&gt;
                    &lt;/tfoot&gt;
                    &lt;tbody&gt;
                        {%- for possibleAsset in possibleAssets %}
                            &lt;tr&gt;
                                &lt;td class=&quot;is-narrow is-vcentered&quot;&gt;
                                    {{ input('checkbox', 'fields[userPortfolio][]', possibleAsset.id, {
                                        checked: possibleAsset.id in relatedAssetIds
                                    }) }}
                                &lt;/td&gt;
                                &lt;td class=&quot;is-narrow is-vcentered&quot;&gt;
                                    {{ possibleAsset.getImg({width: 48, height: 48}) }}
                                &lt;/td&gt;
                                &lt;td class=&quot;is-vcentered&quot;&gt;
                                    {{ possibleAsset.filename }} {{ possibleAsset.folderId }}
                                &lt;/td&gt;
                            &lt;/tr&gt;
                        {%- endfor %}
                    &lt;/tbody&gt;
                &lt;/table&gt;
            &lt;/p&gt;
        {%- endif %}

        {%- if currentUser.userPortfolio|length &lt; 10 %}
            &lt;p class=&quot;control&quot;&gt;
                &lt;div class=&quot;file is-fullwidth&quot;&gt;
                    &lt;label class=&quot;file-label&quot;&gt;
                        &lt;input type=&quot;file&quot; name=&quot;fields[userPortfolio][]&quot; class=&quot;file-input&quot;&gt;
                        &lt;span class=&quot;file-cta&quot;&gt;
                            &lt;span class=&quot;file-icon&quot;&gt;
                                &lt;i class=&quot;fas fa-upload&quot;&gt;&lt;/i&gt;
                            &lt;/span&gt;
                            &lt;span class=&quot;file-label&quot;&gt;Upload a photo&lt;/span&gt;
                        &lt;/span&gt;
                    &lt;/label&gt;
                &lt;/div&gt;
            &lt;/p&gt;

        {%- else %}
            &lt;p&gt;You have reached your maximum 10 allowed photos.&lt;/p&gt;

        {%- endif %}
    &lt;/div&gt;
{%- endif %}

&lt;div class=&quot;field is-grouped&quot;&gt;
    &lt;p class=&quot;control&quot;&gt;
        &lt;button type=&quot;submit&quot; name=&quot;submit&quot; class=&quot;button is-link&quot;&gt;Save Changes&lt;/button&gt;
    &lt;/p&gt;
    &lt;p class=&quot;control&quot;&gt;
        &lt;a href=&quot;{{ url('account') }}&quot; class=&quot;button is-light&quot;&gt;Cancel&lt;/a&gt;
    &lt;/p&gt;
&lt;/div&gt;
&lt;/form&gt;
</code></pre>

CC BY-SA 4.0
2020-07-17T15:59:06.880Z
It would help to post your code?
RitterKnight
CC BY-SA 4.0
2020-07-23T14:19:14.277Z
Sure. I've added my code to the question.
Ian Ebden
CC BY-SA 4.0
2020-07-25T19:13:23.970Z
I tried your code and can confirm what you're seeing. Just filed a [bug report](https://github.com/craftcms/cms/issues/6456) on your behalf.
RitterKnight
<assets-field><entry-form>
Send currentUser id along with uploaded asset
# Send currentUser id along with uploaded asset

(Asked by: username_0 on 2020-07-17)

I've created an entry form with an assets field. All works great, uploading to portfolio/{currentUser.id} directories. On edit forms I only want to list assets uploaded by the currentUser so the .uploader(currentUser) param on the asset query is perfect. BUT... when user uploads assets their id is not being recorded. I can see it listed as NULL in the assets database table. Consequently, the newly uploaded asset won't appear in the existing assets list for the currentUser. Make sense?
So yeah, basically I want front end form asset uploads to record the uploader's id.
Any thoughts much appreciated.
Here's the field in my form...

{{ actionInput('users/save-user') }}
{{ csrfInput() }}
{{ hiddenInput('userId', currentUser.id) }}

{%- set field = craft.app.fields.getFieldByHandle('userPortfolio') %}
{%- if field|length %}
    {# include a hidden input first so Craft knows to update the existing value, if no checkboxes are checked #}
    {{ hiddenInput('fields[userPortfolio]', '') }}
    
    {# get existing assets for this user #}
    {% set possibleAssets = craft.assets()
        .volume('cdn')
        .uploader(currentUser)
        .kind('image')
        .orderBy('filename ASC')
        .withTransforms([
            { width: 100, height: 100 }
        ])
    .all() %}

    {# get the currently related asset IDs #}
    {% set relatedAssetIds = currentUser
        ? currentUser.userPortfolio.ids()
        : [] %}

    
        {{ field.name }}{%- if field.instructions %} {{ field.instructions }}{%- endif %}
        {%- if possibleAssets|length %}
            
                
                    
                        Checkboxes
                        Photo
                        Filename
                    
                    
                        
                            Uncheck an image and save the form to hide it on your public portfolio
                        
                    
                    
                        {%- for possibleAsset in possibleAssets %}
                            
                                
                                    {{ input('checkbox', 'fields[userPortfolio][]', possibleAsset.id, {
                                        checked: possibleAsset.id in relatedAssetIds
                                    }) }}
                                
                                
                                    {{ possibleAsset.getImg({width: 48, height: 48}) }}
                                
                                
                                    {{ possibleAsset.filename }} {{ possibleAsset.folderId }}
                                
                            
                        {%- endfor %}
                    
                
            
        {%- endif %}

        {%- if currentUser.userPortfolio|length < 10 %}
            
                
                    
                        
                        
                            
                                
                            
                            Upload a photo
                        
                    
                
            

        {%- else %}
            You have reached your maximum 10 allowed photos.

        {%- endif %}
    
{%- endif %}


    
        Save Changes
    
    
        Cancel

**Tags:** assets-field, entry-form
> **Comments:**
> **username_1**: It would help to post your code?  
> **username_0**: Sure. I've added my code to the question.  
> **username_1**: I tried your code and can confirm what you're seeing. Just filed a [bug report](https://github.com/craftcms/cms/issues/6456) on your behalf.  

---

## 1 answers

### Answer by username_0 on 2020-07-27. Score: 2 | Accepted answer

Thanks for the assist. Just updated my Craft and all sorted.

> **Comments:**
> **username_1**: Fixed in Craft CMS 3.4.30 - as of 7/27/20.  

---

