I have a problem while creating dynamic form in antd4, following this example from docs.
I want to use dynamic form to edit object which already has some values.
In this sandbox I created a new array of initial values: https://codesandbox.io/s/dynamic-form-item-ant-design-demo-slm8o?file=/index.js:636-649
The goal is to achieve this state when opening form:
Grateful for any help.
You need to pass an object to initialValues
prop, that contains an array of values for names
field list, like so:
<Form
name="dynamic_form_item"
initialValues={{ names: ['', '', ''] }}
{...formItemLayoutWithOutLabel}
onFinish={onFinish}
>
<Form.List name="names">
{ /* your array of fields goes here */ }
</Form.List>
</Form>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With