form is not resetting its value
See original GitHub issuemy submit function
submit = (values) => {
return axios
.post('shops', values)
.then((res) => {
alert.success('Shop Created.'); // on success, its showing
this.refs.newShopForm.reset(); // but this is not setting forms value
})
.catch((err) => {
this.refs.newShopForm.updateInputsWithError(err.response.data); // on error, its showing errors
});
};
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:17
Top Results From Across the Web
Form resetting is not working - Stack Overflow
If your objective is only to reset the form, you could try this: <input type="reset" id="reset" value="Reset" onclick="this.form.reset();"/>.
Read more >ReserForm() not resetting all values on the form
Solved: Hello Experts , i am writing reset form on my form submission button but it does not reset value for some of...
Read more >HTMLFormElement.reset() - Web APIs | MDN
The HTMLFormElement.reset() method restores a form element's default values. This method does the same thing as clicking the form's <input ...
Read more >Using JavaScript to reset or clear a form
These methods are very convenient to use, but they do not provide the functionality of clearing all the fields, including their default values....
Read more >HTML DOM Form reset() Method - W3Schools
The reset() method resets the values of all elements in a form (same as clicking the Reset button). Tip: Use the submit() method...
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 Free
Top 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
I had the same problem but just with textarea fields. I have a formsy-react wrapper for my input components so I can use them with o without formsy-react. Calling reset was cleaning the values as expected but passing
undefined
as a value to the children component didn’t updated it so I end up passingvalue={this.getValue() || ''}
and that solved the issueCannot for the life of me get the from to reset its inputs. Trying:
Tried passing value={this.state.something} and then calling this.setState({value: ‘’}) on submit. That didn’t work either.