Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form dynamic setFields Error #21962

Closed
1 task done
satanYuTeng opened this issue Mar 7, 2020 · 6 comments
Closed
1 task done

Form dynamic setFields Error #21962

satanYuTeng opened this issue Mar 7, 2020 · 6 comments

Comments

@satanYuTeng
Copy link

satanYuTeng commented Mar 7, 2020

  • I have searched the issues of this repository and believe that this is not a duplicate.

Reproduction link

https://3x.ant.design/components/form-cn/#components-form-demo-dynamic-form-item

Steps to reproduce

{getFieldDecorator(names[${k}], {
validateTrigger: ['onChange', 'onBlur'],
rules: [
{
required: true,
whitespace: true,
message: "Please input passenger's name or delete this field.",
},
],

this.props.form.setFields({
names:{
value:[1,1],
errors:[new Error('test')]
}
});

对 names 使用 setFields 会报错
Warning: You cannot set a form field before rendering a field associated with the value.

What is expected?

setFields 可以对 数组形式的装饰字段使用

What is actually happening?

对 names 使用 setFields 会报错
Warning: You cannot set a form field before rendering a field associated with the value.

Environment Info
antd 3.26.12
React 16.6
System mac
Browser chrome
@afc163
Copy link
Member

afc163 commented Mar 7, 2020

Duplicate of #8880

Don't forget getFieldDecorator('names', { initialValue: [] }); before using setFields.

@afc163 afc163 closed this as completed Mar 7, 2020
@satanYuTeng
Copy link
Author

image
使用 getFieldDecorator('names', { initialValue: [] }) 会得到另外一个错误
Warning: One field name cannot be part of another, e.g. a and a.b. Check field: names[0]

@satanYuTeng
Copy link
Author

并没有解决问题

@satanYuTeng satanYuTeng changed the title Form dynamic setFields Error Form dynamic setFields Error (已关闭但未解决问题) Mar 7, 2020
@satanYuTeng
Copy link
Author

image
使用 getFieldDecorator('names', { initialValue: [] }) 会得到另外一个错误
Warning: One field name cannot be part of another, e.g. a and a.b. Check field: names[0]

getFieldDecorator('names', { initialValue: [] }); 这句话加在 render() 里面也是一样的结果

@afc163
Copy link
Member

afc163 commented Mar 7, 2020

#8806

@satanYuTeng satanYuTeng changed the title Form dynamic setFields Error (已关闭但未解决问题) Form dynamic setFields Error Mar 7, 2020
@yanlee26
Copy link

not work yet codepen.io

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants