Excel upload validation in Resource Action
I'm looking to validate an Excel import (maatwebsite/excel:^3.1) inside a resource action.
Currently I'm using a closure rule, where I'm collecting all errors from the Excel import:
The above works, but I cannot find a way to print every error on a line. Is there a way to do this?
I've also tried validating in the action callback... but I can only find how to send notifications from there, and cannot seem to insert validation errors back to the form there.
(when it works I'll add a parameter to the import construction to ignore the collection and only run the validation)
Thanks in advance!
5 Replies
Did you look at the filament Import Plugin?
https://filamentphp.com/plugins/import
https://github.com/konnco/filament-import#validation
You can then add validation to the field it's self too.
Filament
Import by Franky So - Plugins - Filament
import without the need to do templates. all you have to do is drag and drop and match the fields and columns of your file, and let the magic happens!
GitHub
GitHub - konnco/filament-import: why import must use a template whe...
why import must use a template when you can import all files dynamically? - GitHub - konnco/filament-import: why import must use a template when you can import all files dynamically?
I've seen the package, but that one only does (mass) inserts right? I'll need to do custom logic of how the imported rows are processed, which could be done inside the Import class from maatwebsite/excel using the ToConcern collection.
It works, but it closes the modal and throws the errors as a notification as well, doesn't seem ideal.
Did you read the github docs?
https://github.com/konnco/filament-import#disable-mass-create
GitHub
GitHub - konnco/filament-import: why import must use a template whe...
why import must use a template when you can import all files dynamically? - GitHub - konnco/filament-import: why import must use a template when you can import all files dynamically?
Yeah, but validation works less good than my custom soluton above - the modal is closed (we keep it open) and validation goes into notifications