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()
        .orderBy('filename ASC')
            { 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">
                        <th class="is-narrow"><span class="is-hidden">Checkboxes</span></th>
                        <th class="is-narrow">Photo</th>
                            <td colspan="3" class="has-text-grey-light">Uncheck an image and save the form to hide it on your public portfolio</td>
                        {%- for possibleAsset in possibleAssets %}
                                <td class="is-narrow is-vcentered">
                                    {{ input('checkbox', 'fields[userPortfolio][]', possibleAsset.id, {
                                        checked: possibleAsset.id in relatedAssetIds
                                    }) }}
                                <td class="is-narrow is-vcentered">
                                    {{ possibleAsset.getImg({width: 48, height: 48}) }}
                                <td class="is-vcentered">
                                    {{ possibleAsset.filename }} {{ possibleAsset.folderId }}
                        {%- endfor %}
        {%- 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 class="file-label">Upload a photo</span>

        {%- else %}
            <p>You have reached your maximum 10 allowed photos.</p>

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

<div class="field is-grouped">
    <p class="control">
        <button type="submit" name="submit" class="button is-link">Save Changes</button>
    <p class="control">
        <a href="{{ url('account') }}" class="button is-light">Cancel</a>
  • 1
    It would help to post your code? Commented Jul 17, 2020 at 15:59
  • Sure. I've added my code to the question.
    – Ian Ebden
    Commented Jul 23, 2020 at 14:19
  • I tried your code and can confirm what you're seeing. Just filed a bug report on your behalf. Commented Jul 25, 2020 at 19:13

1 Answer 1


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

  • Fixed in Craft CMS 3.4.30 - as of 7/27/20. Commented Jul 28, 2020 at 19:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.