Don't unset the #submit callback

Created on 29 October 2021, about 3 years ago
Updated 31 January 2024, 11 months ago

Problem/Motivation

When using other modules, such as media entity file replace, which add their own custom submit handler, this module prevents those from working. It does this by completely clearing out the value of $form['actions']['submit']['#submit'] and then applying an ajax submit handler instead.

Steps to reproduce

  1. Install the media entity file replace module and add it to the form for at least one media type
  2. Enable this module for any given media entity reference field
  3. Edit an existing media entity using this module that is also using media entity file replace, and try uploading a replacement file
  4. Save the media entity, then go to Content -> Files. You will see the file uploaded to replace the existing one, but still marked as temporary and used in 0 places
  5. Go back to editing the media entity for which you tried to replace the file, and check the file that is attached - open that file to view it, refresh a few times to make sure you are not viewing a cached image. It will be the same image as before, and not replaced as expected

Proposed resolution

See this core issue Allow media items to be edited in a modal when using the field widget Postponed . It is aimed to resolve the same problem, and it may end up coming to Drupal core once they have worked through the various concerns identified with it.

The patch provided on that issue works, so if this module is not working for you then use that patch instead.

This module could be updated based on that latest patch in order to allow other submit handlers, such as the one in media entity file replace, to work properly.

🐛 Bug report
Status

Needs work

Version

3.0

Component

Code

Created by

🇨🇦Canada teknocat

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.

Production build 0.71.5 2024