I have the following react-bootstrap
component:
<FormGroup onSubmit={this.gotEmail} role="form">
<FormControl type="text" className="form-control"/>
<Button className="btn btn-primary btn-large centerButton" type="submit">Send</Button>
</FormGroup>
I would like the form to be submitted when I click the button "Send".
However, if I click the button, control doesn't reach the this.gotEmail
method.
Why is that the case?
FormGroup
does not provide on submit event. You can wrap it with form
element and attach event handler to it:
<form onSubmit={this.gotEmail}>
<FormGroup role="form">
<FormControl type="text" className="form-control"/>
<Button className="btn btn-primary btn-large centerButton" type="submit">Send</Button>
</FormGroup>
</form>