question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

You cannot set field before registering it when set the value to dynamic form item

See original GitHub issue

Version

3.1.1

Environment

MAC 、chrome 63.0.3239.84 (64)、antd 3.1.1

Reproduction link

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

Steps to reproduce

Dynamic form item set value,
` const formItems = keys.map((k, index) => { return ( <FormItem {…formItemLayoutWithOutLabel} required={true} key={k} > {getFieldDecorator( minAmount-${k} , { rules: [{ required: true, message: “请输入大于0的值”, }], })( <InputNumber min={0.01} style={{ width: ‘10%’, marginRight: 8 }} disabled={this.state.saveDisable} placeholder=“大于0的值” step={0.01} /> )}

      { (keys.length > 1) ? (
        <Button
        type="danger"
        disabled={keys.length === 1}
        onClick={() => this.remove(k)}
        >删除</Button>
      ) : null}
    </FormItem>
  );
});

Example this.props.form.setFields( { "minAmount-1" : {value : 111} } ); .

What is expected?

Set value as common fields.

What is actually happening?

You cannot set field before registering it.


When edit the row data and set the data to dynamic form item .

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:48 (7 by maintainers)

github_iconTop GitHub Comments

141reactions
yanzishangcommented, May 22, 2018

if your form doesn’t have the fields these you set, this error will appear!

130reactions
naeflcommented, Feb 13, 2018

Same problem. English please.

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - ANTD dynamic form - initial values - Stack Overflow
I am getting this error: You cannot set field before registering it. import React from "react"; import { Select, Icon, Button, Form, Input...
Read more >
Form - Ant Design
High performance Form component with data scope management. Including data collection, verification, and styles.
Read more >
useForm - setValue - React Hook Form
This function allows you to dynamically set the value of a registered field and have the options to validate and update the form...
Read more >
How to Dynamically Modify Forms Using Form Events - Symfony
Example: on a registration form, you have a "country" field and a "state" field which should populate dynamically based on the value in...
Read more >
Dynamic Forms Tips and Considerations - Salesforce Help
OData Callout Rate Limit Considerations for Salesforce Connect—OData... Set Predefined Field Values for Quick Action Fields · Fields in Party Consent Records ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found