How to set hidden fields in redux form in react native ?
i jsut cannot find any way on how to do that . any help?
How to set hidden fields in redux form in react native ?
i jsut cannot find any way on how to do that . any help?
you don't need to dispatch any action just perform this change whenever you need a hidden field in redux form.
this.props.change('Field_name', value)
Technically you don't need to create a type=hidden field because you can call the change function for the 'hidden' field you want to change if the field doesn't exist Redux-form will add it to your form state like an actual field
MyForm = reduxForm({
form: 'myForm'
})(MyForm)
MyForm = connect(
state => ({
initialValues: { areYouOk: 'no' }
})
)(MyForm)
export default MyForm
Whether you've set up initial values or not you'll always be able to call the change function with your new hidden value and it'll work anyway
let MyForm = ({ submitHandler, change }) => {
return (
<form onSubmit={submitHandler}>
<button
onClick={() => {
change('areYouOk', 'yes');
}}
label={'Yes'}
/>
</form>
);
}