Trying to figure out how to dynamically handle a varying amount of props data for a form. My google hunt has come up with nothing. I'm collecting data on number of appointments based on number dogs a related user has. So props would look like this:
this.props: {
user: {
id: 11
name: "Steve",
age: 32
}
dogs: [{
id: 18,
name: "Rover"
},{
id: 42,
name: "Snugglemittens"
}]
}
Every user has a different number of dogs. And my parent element view looks like this:
render(){
<form onSubmit={this._handleSubmit.bind(this)}>
{this.props.dogs.map((dogge)=>{
return(<MsgView dog={dogge} key={dogge.id} />;)
}}
<button type="submit">Submit</button>
</form>
}
Then inside each Message view I want to collect two check boxes about each dog:
render(){
<div className="form-group" data-toggle="buttons">
<label><input type="checkbox" autoComplete="off"/> XYZ </label>
</div>
<div className="form-group" data-toggle="buttons">
<label><input type="checkbox" autoComplete="off"/> ABC </label>
</div>
}
I'm not sure how to get the filled in data back to my backend using ajax. My initial thought was to use state to collect the info and send it back all at once. I'm pretty sure React can pass a function through a prop that I can use, but I can't find a good example.
Redux-form?handleFormSubmit()method that initiates or sends a request with the data to your backend.