Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

react-form nested lists and dynamic lists #2373

Open
3 of 4 tasks
jaret32 opened this issue Aug 10, 2022 · 2 comments
Open
3 of 4 tasks

react-form nested lists and dynamic lists #2373

jaret32 opened this issue Aug 10, 2022 · 2 comments
Labels
Type: Feature Request 🙌 Request a new feature or changes to an existing one

Comments

@jaret32
Copy link

jaret32 commented Aug 10, 2022

Overview

Add support for nested lists and dynamic lists to the react-form package.

Type

  • New feature
  • Changes to existing features

Motivation

I am trying to use the react-form package to model a form where one of the fields is a dynamic list of fields and one of those fields is also a dynamic list. Extending the example provided in the useDynamicList section of the documentation, let's say a card also has a list of qualified users. I tried the approach below by calling useDynamicList in the card factory, but that did not work, and I don't know if there is an easy way to make this work.

interface QualifiedUser {
  name: string;
  limit: number;
}

const qualifiedUserFactory = (): QualifiedUser => ({
  name: '',
  limit: 0
});

interface Card {
  id: string;
  cardNumber: string;
  cvv: string;
  qualifiedUsers: QualifiedUser[];
}

const emptyCardFactory = (): Card => ({
  id: Date.now().toString(),
  cardNumber: '',
  cvv: '',
  qualifiedUsers: useDynamicList([], qualifiedUserFactory)
});

const {
  fields,
  addItem,
  removeItem,
  moveItem,
  reset,
  dirty,
  value,
  newDefaultValue,
  defaultValue,
} = useDynamicList([], emptyCardFactory);

Checklist

  • Please delete the labels section before submitting your issue
  • I have described this issue in a way that is actionable (if possible)
@jaret32 jaret32 added the Type: Feature Request 🙌 Request a new feature or changes to an existing one label Aug 10, 2022
@huykon
Copy link

huykon commented Aug 9, 2024

Did you found the solution?

@vincaslt
Copy link

I too need to support nested lists like this:Image

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Type: Feature Request 🙌 Request a new feature or changes to an existing one
Projects
None yet
Development

No branches or pull requests

3 participants