solid-forms icon indicating copy to clipboard operation
solid-forms copied to clipboard

Feature Request: reset a form

Open kyeotic opened this issue 2 years ago • 3 comments

There does not appear to be a way to fully reset a form. Using setValue on the controls doesn't update the dirty | touched state, so any validators that fail on empty get shown. It's also a bit awkward to have to manually re-define the values instead of having a one stop form.reset() method.

kyeotic avatar Dec 17 '22 01:12 kyeotic

There does not appear to be a way to fully reset a form.

Ya, there's not a method to do this at the moment.

jorroll avatar Dec 28 '22 08:12 jorroll

I just found your blog post about this, and I know this is extremely premature seeing as I haven't looked through the repo, but if you are able to do this const controls = () => control().controls; then couldn't you create a for each loop that grabs all of the fields/ properties connected to controls and clear them out? I know it's probably a lot more complicated than that but I figured I'd at least ask.

Anyways thanks for making and sharing this component!

whoiscarlo avatar Apr 11 '23 21:04 whoiscarlo

then couldn't you create a for each loop that grabs all of the fields/ properties connected to controls and clear them out?

Not sure who your comment is directed to, but yes it is possible to manually (re)set a form control to an arbitrary state. This is a request to add a convenience method to help with that.

jorroll avatar Apr 12 '23 20:04 jorroll