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

[BUG] ValidUploadMultiple - False validation while updating #983

Open
karandatwani92 opened this issue May 13, 2024 Discussed in #982 · 2 comments
Open

[BUG] ValidUploadMultiple - False validation while updating #983

karandatwani92 opened this issue May 13, 2024 Discussed in #982 · 2 comments
Assignees
Labels
bug Something isn't working Priority: MUST

Comments

@karandatwani92
Copy link

karandatwani92 commented May 13, 2024

Discussed in #982

Originally posted by marctaule May 11, 2024
Hi!
I have a problem with the 'upload_multiple' field when updating content.
I have the 'images' field among others, and it's an optional field.
If I don't have any image and I add one, it works correctly. But when I try to edit other fields, it always tells me: 'The images field must be a file of type: jpeg, png, jpg, gif, svg.'
I attach the code I have:
This is my rule:
public function rules() { return [ 'name' => 'required|string', 'images' => ValidUploadMultiple::field()->file('mimes:jpeg,png,jpg,gif,svg|max:2048'), ]; }

This is my code in CrudController:
CRUD::field([ 'name' => 'images', 'label' => 'Images', 'type' => 'upload_multiple', 'withFiles' => [ 'disk' => 'public', // the disk where file will be stored 'path' => 'images', // the path inside the disk where file will be stored ], 'wrapper' => [ 'class' => 'form-group col-md-6 mb-3' ] ]);

I try different type of field in my database: text, varchar and json and no one work :(

Can anyone help me?

Thanks!

[BUG-TLDR]

Throws false validation error when upload_multiple already has an item and we update without changes.

CRUD::field(
[
   'name'      => 'images',
   'label'     => 'Images',
   'type'      => 'upload_multiple',
   'withFiles' => [
       'disk' => 'public',
       'path' => 'images'
    ],
   'wrapper' => ['class' => 'form-group col-md-6 mb-3']
]);
public function rules()
{
   return [
       'images' => ValidUploadMultiple::field()->file('mimes:jpeg,png,jpg,gif,svg|max:2048')
    ];
}
@marctaule
Copy link

Hi! When do you think you will be able to fix this bug? I need it for one of my projects :( Thanks!

@karandatwani92
Copy link
Author

Hey @marctaule
Sorry for the inconvenience.

We are doing a big rework on uploaders, adding tests, bug fixes, and drag-drop Ajax upload support for the editor(similar to the GitHub comment box), etc. It is our priority and is currently in the test phase. It's big, thus taking time. It's in Laravel-Backpack/CRUD#5478

Meanwhile, you can do this:

  • Create a custom validation class extending Backpack\CRUD\app\Library\Validation\Rules\ValidUploadMultiple
  • Fix it in your class and use it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Priority: MUST
Projects
Status: No status
Development

No branches or pull requests

3 participants