Reputation: 25
in my code im using a Dialog component from 'material-ui/Dialog'
import React, {Component} from 'react';
import Dialog from 'material-ui/Dialog';
import FlatButton from 'material-ui/FlatButton';
import {reduxForm, Field} from 'redux-form';
class NewTaskDialog extends Component{
render(){
return (
<Dialog
title="New Task"
modal={false}
actions={[<FlatButton type="submit" label="Ok" primary={true} onTouchTap={this.props.onRequestClose} />]}
open={this.props.open}
onRequestClose={this.props.onRequestClose}
>
<form onSubmit={this.props.handleSubmit}>
<Field component="input" name="name" />
</form>
</Dialog>
);
}
}
NewTaskDialog = reduxForm({
form: 'NewTaskForm'
})(NewTaskDialog);
export default NewTaskDialog;
so since the Dialog accepts actions
prop, how can the button inside of actions be used as a submit trigger ?
Upvotes: 2
Views: 3099
Reputation: 116
You can use HTML5 <button>
attribute "form"
:
<form id="my-id">
<input />
</form>
<button type="submit" form="my-id">Submit</button>
Upvotes: 2
Reputation: 20037
You have three options:
<form />
and then call submit()
on the reference whenever the dialog button is clicked<form />
and manually trigger onClick
there via refI'd go with the first approach because of its simplicity.
Upvotes: 1