Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[V6] Submitting with no registered fields #1231

Closed
mike1808 opened this issue Jun 28, 2016 · 4 comments
Closed

[V6] Submitting with no registered fields #1231

mike1808 opened this issue Jun 28, 2016 · 4 comments

Comments

@mike1808
Copy link
Contributor

mike1808 commented Jun 28, 2016

I have the multistep wizard form which last step has no field, just a plain submit button.

Let's consider the follow example:

function WizardFirstStep({ handleSubmit }) {
  return (
    <form onSubmit={handleSubmit}>
      <Field name="username" component="input" type="text" />
      <Field name="password" component="input" type="password" />
    </form>
  );
}

export default reduxForm({
  form: 'wizard',
  destroyOnUnmount: false,
})(WizardFirstStep);
function WizardSecondStep({ handleSubmit }) {
  return (
    <form onSubmit={handleSubmit}>
      <button type="submit">Submit</button>
    </form>
  );
}

export default reduxForm({
  form: 'wizard',
  destroyOnUnmount: false,
})(WizardSecondStep);

And also the main component which changes these steps (like in the examples).

The issues is the following: in the reducer of UNREGISTER_FIELD action if the there is no fields registeredFields property is removed and when you try to submit with the removed property ReduxForm:getFieldList() method will throw an error.

I think that you shouldn't remove the registeredFields property from the state and let it to be an empty array.

One workaround for this is to create a hidden field <Field name="hidden" component="input" type="hidden" /> just to make that property not to be empty.

@ooflorent
Copy link
Contributor

@clayne11 could you take a look at this issue please?

@clayne11
Copy link
Contributor

I'll look at it. Should be a simple fix.

@erikras
Copy link
Member

erikras commented Jul 1, 2016

Published fix in v6.0.0-rc.1.

@erikras erikras closed this as completed Jul 1, 2016
@lock
Copy link

lock bot commented Jun 2, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants