0

enter image description here

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?

Sandbox example

4
  • Please post your code. Commented May 1, 2018 at 13:56
  • screenshots added Commented May 2, 2018 at 8:02
  • codesandbox.io/s/zrw3lkjrr4 Commented May 2, 2018 at 9:37
  • Please don't add screenshots, copy and paste your code. Commented May 2, 2018 at 10:36

1 Answer 1

2

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)));
      }
    });
  }

Updated example

Sign up to request clarification or add additional context in comments.

1 Comment

looks good, how can I fire validation in those forms so it will display error

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.