Form Within Modal - formData submitted returns undefined
See original GitHub issuethe onSubmit handler given inn the below code snippet returns undefined. I need some help on this.
import React, {Component} from "react";
import ReactDOM from "react-dom";
import { Button, Checkbox, Form, Input, Message, Radio, Select, TextArea , Modal} from "semantic-ui-react";
export class NewDiseaseModal extends Component {
constructor() {
super();
this.state = {
formData: {},
modalOpen: true
};
}
handleSubmit(e, {formData}) {
e.preventDefault();
console.log(formData);
}
render() {
const {formData} = this.state;
return(
<Modal open={this.state.modalOpen}>
<Modal.Header>
Add New Disease
</Modal.Header>
<Modal.Content>
<Form onSubmit={this.handleSubmit}>
<Form.Field>
<Form.Input type='text' name='username' label="username" />
</Form.Field>
<Button primary type='submit'>Submit</Button>
<Message>
<pre>formData: {JSON.stringify(formData, null, 2)}</pre>
</Message>
</Form>
</Modal.Content>
</Modal>
);
}
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
AngularJS modal dialog form object is undefined in controller
AngularJS modal dialog form object is undefined in controller · I had similar issue - the problem is that $modal creates two scopes...
Read more >Issue submitting form data from bootstrap 4 modal - Laracasts
I cannot get data to submit from a modal in laravel. When I use the below code and hit the 'add user' button,...
Read more >Form loaded in ajax modal return error on submit
I usually open the form inside modal after generate it from an ajax call. after generate I init It and all seems to...
Read more >Adding a new todo form: Vue events, methods, and models
Add a data() method to our ToDoForm component object that returns a label field. We can set the initial value of the label...
Read more >Modal and AJAX forms - MoodleDocs
the form is already present on the page, we just want to handle submit button in the AJAX requests and not refresh the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
As of
0.66
there is noformData
. See https://github.com/Semantic-Org/Semantic-UI-React/pull/1367 for upgrade guide and more info.You’ll notice that example is gone on master now. We’re shipping more examples, which you can preview here:
Examples/collections/Form/Usage/FormExampleCaptureValues.js Examples/collections/Form/Usage/FormExampleClearOnSubmit.js