Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uploaded By Field in Asset Blank When Using Front End Upload #6456

Closed
RitterKnightCreative opened this issue Jul 25, 2020 · 3 comments
Closed
Labels
bug severity:normal Bugs that affect typical usage

Comments

@RitterKnightCreative
Copy link

RitterKnightCreative commented Jul 25, 2020

Description

The new 3.4 uploaded by (uploader) field is blank on submissions sent from the front end.

When an authenticated user is logged in, the asset should get set to the current user's ID but that's not happening.

Steps to reproduce

  1. Setup a front-end entry form to accept an asset inside an asset field into an entry or user. Sample code below.
  2. Submit the form
  3. The Asset gets uploaded properly but Uploaded By attribution is null.

I would expect this with anonymous users, but it's happening for authenticated ones as well—I tried with a logged in, admin user.

Additional info

  • Craft version: 3.4.29.1
  • PHP version: 7.3
  • Database driver & version: MySQL

Sample Code

More or less pulled from the Craft docs.

Setup an asset field (userPortfolio) and attach to a section (or user).

If I set {author.username} on the Default Upload Location, it even knows the user's username and puts it in the right folder.

This recently came up on the Craft CMS stack exchange.

{% set entry = entry ?? create('craft\\elements\\Entry') %}

<form method="post" accept-charset="UTF-8" enctype="multipart/form-data">

  {{ csrfInput() }}
  {{ actionInput('entries/save-entry') }}
  {{ hiddenInput('sectionId', '1') }}
  {{ hiddenInput('enabled', '1') }}

  <label for="title">Title</label>
  {{ input('text', 'title', entry.title, {
    id: 'title',
    class: entry.hasErrors('title') ? 'error',
  }) }}
  {{ _self.errorList(entry.getErrors('title')) }}


{{ input('file', 'fields[userPortfolio][]', options={
  multiple: true,
}) }}

  <input type="submit" value="Publish">
</form>
@brandonkelly
Copy link
Member

Thanks for pointing that out! Just fixed for the next release.

To get the fix early, change your craftcms/cms requirement in composer.json to:

"require": {
  "craftcms/cms": "dev-develop as 3.4.29.1",
  "...": "..."
}

Then run composer update.

@brandonkelly brandonkelly added bug severity:normal Bugs that affect typical usage and removed bug labels Jul 26, 2020
@brandonkelly
Copy link
Member

Craft 3.4.30 is out now with that fix.

brandonkelly added a commit that referenced this issue Aug 28, 2020
Change from 370a2e2 got lost in merge commit 40b7868
@brandonkelly
Copy link
Member

That bug made its way back into Craft 3.5, and is now fixed once again for 3.5.8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug severity:normal Bugs that affect typical usage
Projects
None yet
Development

No branches or pull requests

2 participants