Fix validation on file.js for multi-value file upload inputs

Created on 22 May 2025, 2 months ago

Problem/Motivation

When using the file_generic widget with a multivalue field, JavaScript extension validation fails if the first file has a valid extension but one of the subsequent files does not.

Steps to reproduce

  1. Create a field of type file that is multivalue and allows only specific extensions, e.g., PDFs.
  2. Try uploading multiple files at once. Ensure the first file has a disallowed extension. JavaScript validation detects this and shows an error β€” this is correct.
  3. Try uploading multiple files at once. Ensure the first file has an allowed extension, but one of the others does not. JavaScript validation passes β€” this is incorrect.

Proposed resolution

Improve Drupal.file.validateExtension() in file.js to validate all files, not just first one.

Remaining tasks

Review.

User interface changes

-

Introduced terminology

-

API changes

-

Data model changes

-

Release notes snippet

Fix validation on file.js for multi-value inputs

πŸ› Bug report
Status

Active

Version

11.2 πŸ”₯

Component

file system

Created by

πŸ‡΅πŸ‡±Poland gugalamaciek

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

Comments & Activities

Production build 0.71.5 2024