vantezzen / auto-form

🌟 A React component that automatically creates a @shadcn/ui form based on a zod schema.
https://vantezzen.github.io/auto-form/
2.29k stars 81 forks source link

Array support? #5

Closed EliasGcf closed 11 months ago

EliasGcf commented 11 months ago

Would be nice to support ZodArray type. React Hook Form has a useFieldArray hook to help add, remove, etc.

vantezzen commented 11 months ago

Good idea - do you have any specific use-cases in mind for this? Just so I can get an idea of how it should behave

EliasGcf commented 11 months ago

Good idea - do you have any specific use-cases in mind for this? Just so I can get an idea of how it should behave

@vantezzen , my use-case is for an array of objects, but I think this feature should allow any registered shape (number, string, etc) and include buttons to add, remove, move up, and down (useFieldArray allow this)

Visually, something like this:

image

vantezzen commented 11 months ago

Just added basic support for arrays, might look into improving the design and adding more advanced features like reordering in the future - otherwise PRs are welcome!

https://github.com/vantezzen/auto-form#arrays