rare-sapphire
rare-sapphire3y ago

how to use form.setFields in checkbox

form.setFieldsValue({ add: true }); <Form.Item name="add"> <Checkbox>Add</Checkbox> </Form.Item>
4 Replies
flat-fuchsia
flat-fuchsia3y ago
In the above code snippet, I don't think there's a problem with setFields but the problem is Checkbox is not using value (which is the default valueProp the Form.Item passes to the child) but its using checked you can do valuePropName="checked" i guess
rare-sapphire
rare-sapphireOP3y ago
so initially i dont want value to be checked once i click on some button it should get checked .... but if i use valuePropName="checked" initially its getting checked
flat-fuchsia
flat-fuchsia3y ago
But, isn't form.setFieldsValue({ add: true }); responsible for it being checked?
rare-sapphire
rare-sapphireOP3y ago
okay ill check

Did you find this page helpful?