question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Form Within Modal - formData submitted returns undefined

See original GitHub issue

the 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:closed
  • Created 7 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
levithomasoncommented, Mar 31, 2017

As of 0.66 there is no formData. See https://github.com/Semantic-Org/Semantic-UI-React/pull/1367 for upgrade guide and more info.

0reactions
levithomasoncommented, Mar 31, 2017

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found