File fields that are required but not accessible, still throw a required validation error.

Created on 13 May 2024, about 1 year ago

Problem/Motivation

Steps to reproduce

1. Install 'standard'
2. Create a custom module with hook_entity_field_access and let it return Access::forbidden for the 'field_image' field.
3. Create an 'article' and click save.
4. "Image field is required." shows, despite the fact that the field is not even accessible.

Proposed resolution

Other fields that are required but not accessible don't generate violations when empty but not accessible.

A similar issue for the media library was solved here: https://www.drupal.org/project/drupal/issues/3267401 🐛 Media library is showing 'is required message' while the user has no access to the field Fixed

The solution would be similar: check for #access in ManagedFile::validateManagedFile.

Remaining tasks

Write tests.

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Active

Version

11.0 🔥

Component
File system 

Last updated about 14 hours ago

Created by

🇪🇸Spain nuez Madrid, Spain

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024