Add support to create new taxonomy terms (entities) during bulk upload

Created on 9 August 2022, almost 2 years ago
Updated 31 May 2024, 26 days ago

Problem/Motivation

We've added a taxonomy term field to the bulk upload so users can tag the uploaded files with theme. This works fine when users select a taxonomy term that already exists, but it leads to problems when users want to create a new tag.

This results in only the first file being uplaoded and a lot of errors in watchdog (Integrity constraint violation: 1062 Duplicate entry).

Steps to reproduce

Add a taxonomy field to the bulk upload form and create a new term when uploading multiple files.

Proposed resolution

I've added a patch with the solution I've used to fix this issue.

The solution I came up with was to loop through all the fields during the submit function of the form itself. A refrence field value can have 2 options. It either contains a target_id to an existing entity or a new entity object that hasn't been stored yet.
If we encounter the later we save the entity and replace the form_state values with a target_id to the just created entity.

πŸ› Bug report
Status

Needs review

Version

3.0

Component

Code

Created by

πŸ‡³πŸ‡±Netherlands Da_Cloud

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • First commit to issue fork.
  • @codebymikey opened merge request.
  • Status changed to Needs review about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States Kristen Pol Santa Cruz, CA, USA

    @Da_Cloud Thanks. After adding a patch, please move to "Needs review" so people know there is something to code review and manually test.

  • πŸ‡¦πŸ‡ΉAustria daniel.pernold

    Reroll patch for 3.0.2.

  • πŸ‡©πŸ‡ͺGermany stefan.korn Jossgrund

    We encountered the same issue and the patch from #5 fixes it. Thanks.

    I change to "Bug report". And imho this is kind of a serious bug. If Media Bulk Upload does not fully support taxonomy entities this should be mentioned somewhere.

Production build 0.69.0 2024