Media forms with a required select liste field break after first submit

Created on 24 June 2024, 8 months ago

Problem/Motivation

We have media forms with a required field that states whether we own the media, or not (select field, text). If the media items is not owned by us, it is required to have credit provided for where the image came from.

If you fill out the form for a media item, but skip the required field for media ownership, the form will refresh and display the validation error. From here on out the form will not submit no matter what.

Steps to reproduce

We have verified this issue exists using https://simplytest.me/ and just this module

Go there, create a new site with this module.

Add a required select list to the image media type.

Go to create an image, do not select an item, hit submit and get the validation error.

Select a value, attempt to submit. No longer submits and returns the following JS console error:

"An error occurred during the execution of the Ajax response: Error: cannot call methods on dialog prior to initialization; attempted to call method 'close'"

Commenting out media_library_media_modify.module line 213 does remove the issue, but haven't tested what other implications it has, but a decent starting point for folks looking to troubleshoot this.

πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States jnicola

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

Comments & Activities

  • Issue created by @jnicola
  • πŸ‡ΊπŸ‡ΈUnited States jnicola
  • πŸ‡ΊπŸ‡ΈUnited States brockfanning

    Not knowing the background behind this particular form alter, this is a bit of a shot in the dark, but this bit of code does seem to fix the problem for us.

  • Status changed to Needs review 12 days ago
  • πŸ‡ΊπŸ‡ΈUnited States brockfanning
  • πŸ‡ΊπŸ‡ΈUnited States brockfanning

    I should add that, as you can tell from the steps to recreate this above, this is a problem that occurs with regular fields - ie, no "Media with contextual modifications" fields. In other words, the problem happens just by enabling this module. So, although this particular bug is pretty niche, I think this implies that some of the alters/hooks in this module may be having unintended effects.

Production build 0.71.5 2024