Skip to content

[>5.4]: Uploading assets in front-end form replaces existing assets #15809

@tommysvr

Description

@tommysvr

What happened?

Description

Since 5.4.0, a saving an entry in a front-end form replaces existing assets. Verified this was working as expected in 5.3.6

Steps to reproduce

Upload a new asset to an entry with existing assets from a front-end form:

<form method="post" accept-charset="UTF-8" enctype="multipart/form-data">
  {{ csrfInput() }}
  {{ actionInput('entries/save-entry') }}
  {{ hiddenInput('entryId', entry.id) }}

  <label for="title">Title</label>
  {{ input('text', 'title', entry.title, {id: 'title',}) }}

  {% for relatedAssetId in entry.assets.ids() %}
    {{ input('text','fields[assets][]',relatedAssetId) }}
  {% endfor %}

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

  <button type="submit">Publish</button>
</form>

Expected behavior

New asset will be added to existing assets

Actual behavior

All existing assets are removed and only the new asset is saved to the entry

Craft CMS version

5.4.0

PHP version

8.2

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions