0

I want to update a form, so that I have fetch data from backend and display in form.I have declare form data like

constructor()
    {
        super()
        this.state={
          organization:[],
          options:["IT service", "Design"],
          loading:true,
          modalIsOpen: false,
          formData:{
            org_name:'',
            org_code:'',
            org_type:'',
            org_category:'',
            org_location:'',
            org_registration:'',
        }
         
        }

Then my handleinput function

handleInputs = (e) => {
      this.setState ({
        formData:{
        [e.target.name]:e.target.value
        }
       });
    }

and my update url

 updateOrganization = async(e) =>
      {
       const org_id= 
        e.preventDefault();
       const res=await axios.put('http://localhost:8000/api/update_organization',this.state.formData);
       
      }

But have six input fields, but when I trying to submit form I got only one input. I am new in react js.Please Help me

1 Answer 1

2

Try to change your handleInputs function like this:

handleInputs = (e) => {
  this.setState({
    formData: {
      ...this.state.formData,
      [e.target.name]: e.target.value,
    },
  });
};
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.