purescript-halogen-formless
purescript-halogen-formless copied to clipboard
formState.anyTouched
As discussed at https://discourse.purescript.org/t/formless-v4-questions-dirty-state-and-reinitialize-forms/3137/3
The big question here is to decide what to do with ResetField. What happens if you touch only one field then reset it? Should anyTouched be false?
Ahhhh good point. Unless we maintain a set of the keys of changed fields like touchedFields, and then anyTouched could just be a function like size touchedFields > 0?
I'm guessing this would be a Set (Variant fields). Need to do a bit of homework on Variant still but happy to try this.
It seems like we could also do a variation on the allTouched function that works on the FormObject which checks if any field is touched rather than all fields are touched. Perhaps that’s an easier route.
Wouldn't that rely on validation having run for the field though? So for it to work we'd need to set validateOnModify or validateOnChange for the form (or manually trigger validation), which may not be appropriate for all forms.