// React component
import React, { Component } from 'react';
import { Form } from 'formsy-react';
class ExampleForm extends Component {
constructor() {
this.state = { canSubmit: false, };
this.enableSubmit = this.enableSubmit.bind(this);
this.disableSubmit = this.disableSubmit.bind(this);
this.submitValues = this.submitValues.bind(this);
this.handleReset = this.handleReset.bind(this);
}
setSubmit(canSubmit) {
return () => {
this.setState({
canSubmit: true,
});
}
}
submitValues(values) {
console.log(values); // ...code to submit values
}
handleReset() {
this.refs.form.reset();
}
render() {
return (
<Form
onValidSubmit={this.submit}
onValid={this.setSubmit(true)}
onInvalid={this.setSubmit(true)}
ref="form">
{/* Some Input fields */}
<button onClick={this.handleReset}>
Reset
</button>
<button
type="submit"
disabled={!this.state.canSubmit}>
Submit
</button>
</Form>
);
}
}
export default ExampleForm;
Last active
January 25, 2018 06:44
-
-
Save prasanna1211/b67dfdbe9bebea268926ba9d0a669723 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment