Some time we need to set initial values for some elements in Redux Form.
Assume we have two fields in the form
<Field name='data.customer_id' .... />
<Field name='type' .... />
To set initial data, we can use initialValues prop of Redux Form
//noted that the first name of Field has used dot notation format
let values = {
data: {customer_id:100}, type: "car"
}
<myForm initialValues={values} ...... />
Modify other field value by change handler of another field
//can change value for filed data.customer_id
function onChangeForOurTypeField (val) {
this.props.change("data", {customer_id: 0})
}
No comments:
Post a Comment