1 | initial version |
You can use the dependencies
prop of Form.Item
to specify which fields/props the item depends on. This will ensure that form.setFieldsValue
is triggered when any of the dependencies change.
For example, if you have a Form.Item
with multiple elements such as Input
and Checkbox
, you can set the dependencies
prop to an array containing the field names of both elements:
<Form.Item
label="My Field"
dependencies={['myInput', 'myCheckbox']}
>
<Input name="myInput" />
<Checkbox name="myCheckbox">Check me</Checkbox>
</Form.Item>
Now, when you call form.setFieldsValue
to update the value of either myInput
or myCheckbox
, the Form.Item
will be re-rendered and the updated value will be displayed.