vantezzen / auto-form

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

Array values in nested object aren't loaded #51

Open paradisi-davide-servizi opened 10 months ago

paradisi-davide-servizi commented 10 months ago

The AutoFormArray component has a bug in it's hook usage that leads to arrays inside nested objects to not load values.

Original version:

const { fields, append, remove } = useFieldArray({ control: form.control, name, });

Solution:

const { fields, append, remove } = useFieldArray({ control: form.control, name: path.join(".") });

Side note, @vantezzen i'd love to collaborate with you on this repo (mainly fixing the rough edges i find and adding support for translations) but i'm not the best expert in using git. Feel free to let me know if we can have a talk!