-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Short description of the issue
When InputfieldFile is used outside of Page Edit it seems to operate in "old school" mode - it uses InitOldSchool()
in InputfieldFile.js
.
In this mode there are a couple of issues with the preview of filenames that have been uploaded to the field before the form is submitted.
For testing purposes I used some custom JS to get the filenames that have been added to the inputs:
$(document).on('change', '.InputfieldFileUpload input[type=file]', function() {
// Get the names of all the files added to the inputs
var $container = $(this).closest('.InputfieldFile');
var $inputs = $container.find('input[type=file]');
var filenames = [];
$inputs.each(function() {
var files = $(this)[0].files;
for(var i = 0; i < files.length; i++) {
file = files[i];
filenames.push(file.name);
}
});
// Log to console
console.log(filenames);
});
1. When files are added one-by-one to the field then each file is listed in the preview, which is good.
But when multiple files are added at once only one file is shown in the preview.
2. When a file is replaced (by clicking on that file in the preview and selecting a different file), the file is indeed replaced in the input value but the preview does not update to reflect the new filename.
Setup/Environment
- ProcessWire version: 3.0.137