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

Created on 13 May 2024, 6 months ago
Updated 17 July 2024, 4 months 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

Needs work

Version

11.0 πŸ”₯

Component
File systemΒ  β†’

Last updated about 9 hours ago

Created by

πŸ‡ͺπŸ‡ΈSpain nuez Madrid, Spain

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

Comments & Activities

Production build 0.71.5 2024