Skip to content

Instantly share code, notes, and snippets.

@redgeoff
Last active November 5, 2018 17:19
Show Gist options
  • Save redgeoff/4af55f199cc3cae02e4bb1c01bef1f94 to your computer and use it in GitHub Desktop.
Save redgeoff/4af55f199cc3cae02e4bb1c01bef1f94 to your computer and use it in GitHub Desktop.
Autogenerating Forms Old - Conditional Submit
handleSubmit = () => {
const { form } = this.state;
// TODO: Contact some API with the data
console.log("submitting", form.getValues());
// Simulate response from API saying that email address is already in use and report this error
// to the user
if (form.get("fields.email.value") === "taken@example.com") {
form.set({ "fields.email.err": "already in use" });
} else {
// Everything was successful so redirect, show confirmation, etc...
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment