Required attribute on file inputs not working

Created on 16 March 2025, 24 days ago

Problem/Motivation

It seems the required attribute does nothing on file inputs.
This could be a problem for πŸ› #states not affecting visibility/requirement of managed_file Needs work and πŸ› managed_file HTML5 required validation Needs work , these issues will add new ways to have this attribute on input fields so it needs to do something.

This seems to happen because disableFields() in file.js disabled input fields when submitting the form, so the required attribute is not triggered by the browser.
I suppose there is a good reason to do this but it could probably be improved.

Steps to reproduce

Override the input--file.html.twig template to add the required attribute on file inputs.
Add a file field on a node bundle.
Browse to the create form for this bundle.
Leave the file field empty and click on Save: the browser does not prevent submitting the form.

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component

file system

Created by

πŸ‡«πŸ‡·France prudloff Lille

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

Comments & Activities

Production build 0.71.5 2024