gazaskygeeks / mpcc-assistant

Platform to consolidate info/docs from visiting GSG mentors
https://mpcc-assistant.herokuapp.com/
0 stars 0 forks source link

Suggestion: wrap submit-waiver input elements in form tag, it will be easier to get their values #121

Open tomduggan85 opened 6 years ago

tomduggan85 commented 6 years ago

If you put these elements into a

tag, it's a little bit easier to get the input values:

https://github.com/gazaskygeeks/mpcc-assistant/blob/6c0d9f5c76bfbdaaca06b7ae96da798f17b20cd3/src/client/components/waiver/Waiver.js#L44-L50

You add an onSubmit handler to the form tag itself () and remove the onClick handler from the submit button, but keep the button there. Then, in upload(), you can access all of the child input elements by their name attribute like this:

e.target.email.value

You might even be able to get the files[] array on e.target.upload in the same way, I can't quite remember if that works. Then you can build up the FormData object right in the upload function, right before posting to axios.

You might also be able to store any errors in state right in that same function in the code, and then use this.state.error to show the error state in render() instead of having to write out "document.getElementById('irr').textContent = ..."

What do you think?