Reputation: 286
I have an accordion which has 7 steps.
first 6 steps has Next
button and last step has Process
button.
and above accordion there is a Save
button.
Also one can jump to any accordion step any time.
Save button saves all step's forms data and checks validation. Every step's Next button saves that particular form data and checks validation. Process button also submits all step's forms data and checks validation.
I have tried redux-form
. but it is limited to particular step. what about save button click?
Upvotes: 0
Views: 4046
Reputation: 4889
You can use getFormNames
, getFormValues
and isValid
selectors to select your forms state.
const mapStateToProps = state => {
return {
forms: getFormNames()(state).map(formName => ({
formName,
isValid: isValid(formName)(state),
values: getFormValues(formName)(state),
errors: getFormSyncErrors(formName)(state)
}))
};
};
Submit function:
submit() {
const { dispatch, forms } = this.props;
forms.forEach(({ formName, isValid, values, errors }) => {
if (isValid) {
console.log(values);
} else {
dispatch(touch(formName, ...Object.keys(errors)));
}
});
}
Upvotes: 2