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

Form submission should not require a form to be dirty. #954

Closed
Alex-BHN opened this issue Oct 3, 2018 · 2 comments
Closed

Form submission should not require a form to be dirty. #954

Alex-BHN opened this issue Oct 3, 2018 · 2 comments

Comments

@Alex-BHN
Copy link

Alex-BHN commented Oct 3, 2018

Current Behavior

Dirty is computed like this:

const dirty = !isEqual(this.initialValues, this.state.values);

Because of this and the decision to not allow not dirty forms to be submit, if a form isn't modified, it can't be submit.

Steps to Reproduce

Don't modify a form and attempt to submit it.

Expected behavior

An unmodified form should be able to be submit.

Suggested solution(s)

A flag to allow this possibility or removal of the restriction.

Additional context

Imagine a form with a single checkbox. The user should be able to submit this without modification.

CodeSandbox Link:


  • Formik Version: 0.11.11
  • React Version: 16.2.0
  • TypeScript Version:
  • Browser and Version:
  • OS:
  • Node Version:
  • Package Manager and Version:
@Saifadin
Copy link
Contributor

Saifadin commented Oct 8, 2018

const dirty = !isEqual(this.initialValues, this.state.values); is the definition of the dirty state.

But submitting a form without being dirty and touched is possible. There is no check for the dirty before an internal submit execution.

In version 0.11.11 you can also pass isInitialValid to tell formik the form is valid.

@prichodko
Copy link
Collaborator

@Saifadin is correct. Form is always submitted when there are no errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants