Add docs and tests for Field Arrays
crutchcorn opened this issue · comments
Right now, we do support Field Arrays, but their usage is not clear and I have low confidence as a maintainer that we won't break them in the future. Let's update docs and tests for field arrays so that we're able to ship this more confidently.
I just tested this in my prototype. How is the API meant to work? I just iterated over the array and built the field name with the index aka
{ name: `employees[${index}].color` }
This seems to work fine, but DeepKeys
does not support it. Is this how you envision the API for FieldArrays though, @crutchcorn?
Btw my updated prototype is here: https://github.com/Christian24/tanstack-form-lit-prototype/tree/arrays
Upon further investigation it seems correct names look as follows:
{ name: `employees.${index}.color` }
This works and types also work for this.
Interestingly, there seems to be some documentation on the website already: https://tanstack.com/form/latest/docs/guides/basic-concepts#array-fields
I did do a quick find usages on index though and Webstorm said it was used nowhere. So, I have no idea if these examples are correct.
There are also already tests present, so maybe this can be closed @crutchcorn
Yea this deffo can be closed, my bad