Validation error after deleting uploaded file using Filepond
thannaske opened this issue · 0 comments
thannaske commented
- Laravel Version: 10.48.10
- PHP Version: 8.2.12
- Splade JS Version (npm): 1.4.19
- Splade PHP Version (composer): 1.4.19
- Dev environment (OS, Sail/Valet/etc): macOS 14.4.1 (Sonoma), Laravel Valet
Description
When using the Filepond component for uploading multiple files there's an issue when the user removes a file that has already been uploaded. The validation of the subsequent request then fails with the following error:
The attachments.0 field must be a file.
This validation error is raised, although there should no attachment.0
field anymore at all. It seems like deleting a file from the Filepond UI doesn't result in the field being removed from the form payload.
The request validation on the backend looks like this (and works fine when uploading a file and then immediately submitting the form):
<?php
// [...]
use Illuminate\Foundation\Http\FormRequest;
use ProtoneMedia\Splade\FileUploads\HasSpladeFileUploads;
class MessageRequest extends FormRequest implements HasSpladeFileUploads
{
// [...]
public function rules(): array
{
return [
'attachments.*' => ['sometimes', 'file', 'max:102400'],
// [...]
];
}
}
Steps To Reproduce Issue
- Create a simple form with the Filepond upload component
- Point the form towards a controller that performs a input validation
- Upload a file
- Remove the file using the Filepond UI
- Submit the form
- Observe the validation error