Technically, you do not need to create a type = hidden field, because you can call a function changefor the βhiddenβ field that you want to change if the field does not exist. The redux form will add it to the form state, as the actual field
MyForm = reduxForm({
form: 'myForm'
})(MyForm)
MyForm = connect(
state => ({
initialValues: { areYouOk: 'no' }
})
)(MyForm)
export default MyForm
Whether you set the initial values ββor not, you can always call the change function with a new hidden value, and it will still work
let MyForm = ({ submitHandler, change }) => {
return (
<form onSubmit={submitHandler}>
<button
onClick={() => {
change('areYouOk', 'yes');
}}
label={'Yes'}
/>
</form>
);
}
source
share