Added formState.setFields method to be able to update multiple fields at once#91
Open
frontendr wants to merge 1 commit intowsmd:masterfrom
Open
Added formState.setFields method to be able to update multiple fields at once#91frontendr wants to merge 1 commit intowsmd:masterfrom
formState.setFields method to be able to update multiple fields at once#91frontendr wants to merge 1 commit intowsmd:masterfrom
Conversation
…ield values, their errors and their touched and validity state.
Author
|
Hi @wsmd, Is there anything I can do for this issue? Just double checking just to make sure I'm not forgetting to do something :-) |
|
Yep, would love to see this merged! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First of all, thank you very much for this great package! It's an absolute breeze to work with!
One thing I've been missing is the ability to set the values of multiple fields at once. One example for this is when the data is loaded from the server. Currently one must set each field individually in a loop and then all those fields are also marked as
touchedwhich is not the case then.So there was a need to be able to set the values of fields in the state but also manage their
touchedandvaliditystate and while we're at it we could also seterrors.Just setting values is simple:
But to be able to change the
touchedorvaliditystate or seterrorsa secondoptionsargument can be provided:Actually setting the
validityof a field tofalsewhen also providing an error for it is redundant so I took the liberty of marking fields for which errors are provided as invalid if and only if novalidityoption is passed.The same goes for setting the
validityof a field totrue. If a field is valid then you probably don't want to show an error so those are cleared if and only if no errors option is passed.I did my best to make this PR as complete as possible:
index.d.tsfile. (Please check it because I'm no TypeScript expert!)README.md.Hope you appreciate it!
Kind regards,
Johan