Skip to content

Conversation

@the-overengineer
Copy link

Adds support for onSubmitError and onSubmitSuccess handlers to the ResetPasswordForm and the ChangePasswordForm.

Fixes #168

@robertjd
Copy link
Member

robertjd commented Feb 1, 2017

Thanks @Tweety-FER , I can confirm that I can now set those handlers. I did notice an inconsistency that we should handle. In our docs we say that the handlers can be used to pass a different error back, but that's not true in this PR, it just passes back the original error because it's bound.

I'm referring to this example in docs/api.md:

class LoginPage extends React.Component {
  onFormSubmit(e, next) {
    // e.data will contain the data mapped from your form.
    console.log("Form submitted", e.data);

    // To return an error message, call next() as:
    // next(new Error('Something in the form is wrong.'));

    // Or if you want to change the data being sent, call it as:
    // next(null, { myNewData: '123' });

    // If you call next without any arguments,
    // it will simply proceed processing the form.
    next();
  }

  render() {
    return <LoginForm onSubmit={this.onFormSubmit.bind(this)} />;
  }
}

@the-overengineer
Copy link
Author

@robertjd Right you are! Changed the behaviour to use the passed error if it exists, otherwise it uses the old error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants