Answers.Body: <p>Thanks for the assist. Just updated my Craft and all sorted.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-28T19:46:55.707Z
Answers.Text: Fixed in Craft CMS 3.4.30 - as of 7/27/20.
Answers.UserDisplayName: RitterKnight
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-27T08:43:23.787Z
Answers.LastActivityDate: 2020-07-27T08:43:23.787Z
Answers.UserDisplayName: Ian Ebden
Body: <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>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-07-17T15:59:06.880Z
Comments.Text: It would help to post your code?
Comments.UserDisplayName: RitterKnight
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-07-23T14:19:14.277Z
Comments.Text: Sure. I've added my code to the question.
Comments.UserDisplayName: Ian Ebden
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-07-25T19:13:23.970Z
Comments.Text: 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.
Comments.UserDisplayName: RitterKnight
Tags: <assets-field><entry-form>
Title: Send currentUser id along with uploaded asset
ThreadText: # 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...
  
  ```
  <form method="post" accept-charset="UTF-8" enctype="multipart/form-data" autocomplete="on" class="block" id="account">
  {{ 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()
          : [] %}
  
      <div class="field mb-6">
          <label for="{{ field.id }}" class="label">{{ field.name }}{%- if field.instructions %} <span class="label-hint">{{ field.instructions }}</span>{%- endif %}</label>
          {%- if possibleAssets|length %}
              <p class="control">
                  <table class="table is-fullwidth">
                      <thead>
                          <th class="is-narrow"><span class="is-hidden">Checkboxes</span></th>
                          <th class="is-narrow">Photo</th>
                          <th>Filename</th>
                      </thead>
                      <tfoot>
                          <tr>
                              <td colspan="3" class="has-text-grey-light">Uncheck an image and save the form to hide it on your public portfolio</td>
                          </tr>
                      </tfoot>
                      <tbody>
                          {%- for possibleAsset in possibleAssets %}
                              <tr>
                                  <td class="is-narrow is-vcentered">
                                      {{ input('checkbox', 'fields[userPortfolio][]', possibleAsset.id, {
                                          checked: possibleAsset.id in relatedAssetIds
                                      }) }}
                                  </td>
                                  <td class="is-narrow is-vcentered">
                                      {{ possibleAsset.getImg({width: 48, height: 48}) }}
                                  </td>
                                  <td class="is-vcentered">
                                      {{ possibleAsset.filename }} {{ possibleAsset.folderId }}
                                  </td>
                              </tr>
                          {%- endfor %}
                      </tbody>
                  </table>
              </p>
          {%- endif %}
  
          {%- if currentUser.userPortfolio|length < 10 %}
              <p class="control">
                  <div class="file is-fullwidth">
                      <label class="file-label">
                          <input type="file" name="fields[userPortfolio][]" class="file-input">
                          <span class="file-cta">
                              <span class="file-icon">
                                  <i class="fas fa-upload"></i>
                              </span>
                              <span class="file-label">Upload a photo</span>
                          </span>
                      </label>
                  </div>
              </p>
  
          {%- else %}
              <p>You have reached your maximum 10 allowed photos.</p>
  
          {%- endif %}
      </div>
  {%- endif %}
  
  <div class="field is-grouped">
      <p class="control">
          <button type="submit" name="submit" class="button is-link">Save Changes</button>
      </p>
      <p class="control">
          <a href="{{ url('account') }}" class="button is-light">Cancel</a>
      </p>
  </div>
  </form>
  
  ```
  
  **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.  
  
  ---
  
  