How to handle FileList (i.e. input that allows selecting multiple files)? #45
Replies: 1 comment
-
This is a missing feature atm. It's bit tricky to support (but possible). First of all React Zorm only uses Ideally we would support To support this I think we need to add custom a custom type to make it unambiguous. Ex. something like: import { MultipleFiles } from "react-zorm";
const FormSchema = z.object({
files: z.instanceof(MultipleFiles)
}); And use that as a parsing hint. |
Beta Was this translation helpful? Give feedback.
-
There was a discussion about handling single file uploads, but how about multiple?
I modified the single upload code example to show the issue I'm having with FileList: https://codesandbox.io/s/kind-babbage-8oy4ln?file=/src/App.tsx
name={zorm.fields.images()}
fails to:Didn't spot it from the docs but is there a concept of array name without explicitly defining the index? For example
fieldName[]
. That's the recommended way to name a multi-file input: https://stackoverflow.com/questions/1593225/how-to-select-multiple-files-with-input-type-fileBeta Was this translation helpful? Give feedback.
All reactions