I used Material UI Dialog to create a list of forms. In the official case:
<Dialog title="Dialog With Custom Width" actions={actions} modal={true} open={this.state.open} > This dialog spans the entire width of the screen. </Dialog>
actions are:
const actions = [ <FlatButton label="Cancel" primary={true} onTouchTap={this.handleClose} />, <FlatButton label="Submit" primary={true} onTouchTap={this.handleClose} />, ];
How can I create a form and let Dialog submit my form data?
------------------------------------------------ UPDATE- ----------------------------------------------
There is one more answer:
Add the type
and form
attribute to the dialog action button:
const actions = [ <FlatButton label="Cancel" primary={true} onTouchTap={this.handleClose} />, <FlatButton label="Submit" primary={true} onTouchTap={this.handleClose} type="submit"
and assign the attribute identifier to the form in the dialog box:
<Dialog title="Dialog With Custom Width" actions={actions} modal={true} open={this.state.open} > // here can put child component and the code still work even the form is in the child component <div className="deal_form"> <form id="myform" onSubmit = {this.handleCreate} > <TextField value={this.state.staff_number} /> </form> </div> </Dialog>
source share