Quantcast
Channel: User totymedli - Stack Overflow
Viewing all articles
Browse latest Browse all 54

Answer by totymedli for Antd 4 Checkbox doesn't have value after form submit

$
0
0

tl;dr

Add valuePropName="checked" to the Form.Item component:

<Form.Item name="isAccepted" valuePropName="checked">

Explanation

A checkbox's value is not stored in a value attribute like for text inputs. Instead, it has a checked attribute. You have to tell the Form.Item component to set that attribute/prop by telling the prop's name through valuePropName.

The docs on Form.Item describes this prop:

valuePropName: Props of children node, for example, the prop of Switch is 'checked'. This prop is an encapsulation of getValueProps, which will be invalid after customizing getValueProps

Later it describes how the wrapping happens:

After wrapped by Form.Item with name property, value (or other property defined by valuePropName) onChange (or other property defined by trigger) props will be added to form controls, the flow of form data will be handled by Form...


Viewing all articles
Browse latest Browse all 54

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>