ManagedFile widget will cause a "field is required" validation error even if a user does not have access to the field

Created on 31 August 2023, 10 months ago
Updated 4 September 2023, 10 months ago

Problem/Motivation

hook_entity_field_access allows modules to deny a user access to a certain field. However, this field might still be included in a form array even if its #access is set to false.

For most Drupal fields this is not an issue, however the ManagedFile element does not take the status of #access into account and will cause a "X field is required" validation error, even if the user can't see or edit the file.

Steps to reproduce

  1. Create a content type with a field that uses the ManagedFile element in its creation form
  2. Implement a hook_field_access to deny access to the field
  3. As a user without access to the field, try to create that content

Proposed resolution

Make ManagedFile behave like all other field elements and do not enforce required fields when the user does not have access to them.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component
File moduleΒ  β†’

Last updated 3 days ago

Created by

πŸ‡³πŸ‡±Netherlands Kingdutch

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

Comments & Activities

Production build 0.69.0 2024