Problem/Motivation

When a user has no access to the media library item, the media library is still validating the field. This leads to a message 'The image field is required', while the user sees no field to upload a widget.

Steps to reproduce

  • Configure a content type with a required Media field and configure the form display to use the media library widget
  • Enable content translation, and mark your media field as not translatable.
  • Configure translation to hide fields that are not translatable.
  • Create a new node with an image.
  • Translate the node and click on save

Proposed resolution

Add a check to see if the field was visible for the user

Issue fork drupal-3267401

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

nils.destoop created an issue. See original summary.

nils.destoop’s picture

Initial merge requests, but probably still needs some tests

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

acbramley’s picture

Version: 9.4.x-dev » 9.5.x-dev
Status: Active » Needs review
Issue tags: +Bug Smash Initiative
StatusFileSize
new3.04 KB
new3.9 KB

Added tests, this should be red/green.

The last submitted patch, 5: 3267401-5-test-only.patch, failed testing. View results

smustgrave’s picture

Tried verifying this issue.

Enabled a 2nd language
Translate an Article content type but uncheck the image field
Create a node
Add a translation
I don't see the image field (that's good)
I click save (no error)

Is there a step I'm missing?

acbramley’s picture

Issue summary: View changes

@smustgrave did you make the field required? And it needs to use the media library widget. Updated the IS

smustgrave’s picture

So following those steps.

When I go to translate the page I'm seeing my media library field there even though it is unchecked in the content translation page.

smustgrave’s picture

Disregard my previous comment. I was able to generate the error.

I applied the patch but still am not able to get past it.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Having a bad case of the Mondays early. I used the MR and that did not work. Using the patch I was able to save the form.

I see the patch has a red/green pattern so that's good.
Seems like a simple check so I'm comfortable to mark it.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 5: 3267401-5.patch, failed testing. View results

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

luksak’s picture

The MR works great for me.

tjtj’s picture

I am still getting this in Drupal 9.5.3

Add or select media
The media item has been created but has not yet been saved. Fill in any required fields and save to add it to the media library.

    Name European efforts & advances in Stellarator power plant studies
acbramley’s picture

Status: Needs work » Reviewed & tested by the community

Ran #5 against 10.1.x and got the expected red/green combo. The previous failure was a random one. Back to RTBC.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 5: 3267401-5.patch, failed testing. View results

lauriii’s picture

Status: Needs work » Reviewed & tested by the community

Looks like a random fail

  • catch committed f8f6ad83 on 10.1.x
    Issue #3267401 by nils.destoop, acbramley, smustgrave: Media library is...

  • catch committed b8485e75 on 10.0.x
    Issue #3267401 by nils.destoop, acbramley, smustgrave: Media library is...

  • catch committed 58d974e9 on 9.5.x
    Issue #3267401 by nils.destoop, acbramley, smustgrave: Media library is...
catch’s picture

Version: 10.1.x-dev » 9.5.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to 10.1.x, cherry-picked to 10.0.x and 9.5.x, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.