Skip to content

Add docs and tests for Field Arrays #492

Closed

Description

@crutchcorn

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.

Activity

  1. Christian24 commented on Oct 30, 2023

    @Christian24
    Contributor

    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

  2. Christian24 commented on Oct 31, 2023

    @Christian24
    Contributor

    Upon further investigation it seems correct names look as follows:

    { name: `employees.${index}.color` }

    This works and types also work for this.

  3. Christian24 commented on Nov 1, 2023

    @Christian24
    Contributor

    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.

  4. Christian24 commented on Nov 2, 2023

    @Christian24
    Contributor

    There are also already tests present, so maybe this can be closed @crutchcorn

  5. crutchcorn commented on Nov 3, 2023

    @crutchcorn
    MemberAuthor

    Yea this deffo can be closed, my bad

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood for newcomerstype: enhancementThis requests an enhancement to existing behaviour.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions