ant-design form.list add(initvalue) fields.map(item) why item does not contain this add's initvalue

wlzqhblo  于 2022-10-20  发布在  其他
关注(0)|答案(6)|浏览(499)
  • I have searched the issues of this repository and believe that this is not a duplicate.

https://ant.design/components/form-cn/#components-form-demo-dynamic-form-items

Steps to reproduce

  1. 通过按钮添加add(1)
  2. fields.map(field => console.log(field))
  3. field 拿不到初始值,只有默认的{ fieldKey: 0
    isListField: true
    key: 0
    name: 0 }

What is expected?

  1. 既然 form.list add(init, index) 第一个参数接受一个初始值,那么我肯定需要在代码里 判断这个初始值的,可我在fields.map(item) 这里的Item拿不到我的初始值,只有默认的{ fieldKey: 0
    isListField: true
    key: 0
    name: 0 }

What is actually happening?

我想拿到我自己设置的初始值

EnvironmentInfo
antd4.8.0
React16.12
Systemmac
Browserchrome

RT

ecfdbz9o

ecfdbz9o2#

Hello @qiansimin88. Please provide a online reproduction by forking this link https://u.ant.design/codesandbox-repro or a minimal GitHub repository. Issues labeled by Need Reproduce will be closed if no activities in 7 days.

你好 @qiansimin88, 我们需要你提供一个在线的重现示例以便于我们帮你排查问题。你可以通过点击 此处 创建一个 codesandbox 或者提供一个最小化的 GitHub 仓库。7 天内未跟进的 issue 将会被自动关闭。

p1iqtdky

p1iqtdky4#

@zombieJ 可以关了么

fjaof16o

fjaof16o5#

请增加到react-component中在文档当中也体现一下吧,不然没办法去做了。
我已经用Table去做动态增加表单项的操作的,但是还是希望社区统一的办法去修复这个问题。

xxe27gdn

xxe27gdn6#

hello.
i have similar problem:
when add form list field onValuesChange received undefined value for each newly added field
https://stackblitz.com/edit/react-nj4v5o

相关问题