Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation error after deleting uploaded file using Filepond #638

Open
thannaske opened this issue May 13, 2024 · 0 comments
Open

Validation error after deleting uploaded file using Filepond #638

thannaske opened this issue May 13, 2024 · 0 comments

Comments

@thannaske
Copy link

  • 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

  1. Create a simple form with the Filepond upload component
  2. Point the form towards a controller that performs a input validation
  3. Upload a file
  4. Remove the file using the Filepond UI
  5. Submit the form
  6. Observe the validation error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant