Modifies useForm to handle nested data #1338
Open
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.
In relation to this discussion , here's a proposal for using nested form data in the react package. This uses @sbc640964's suggestion to utilize lodash methods, which made sense to me since lodash was already a dependency.
This also adds a
getData
function which is essentially just an alias for the lodashget
function. Purely a convenience method which will help to build custom form and input components.Since part of the goal is to make the form hook more compatible with backend data, I also included a sanitizer which processes the data passed in. React doesn't like when a controlled input's value changes from null or undefined to a value, it wants empty inputs to be an empty string. Converting null and undefined values into empty strings allows us to directly pass in empty objects from our controllers, which mimics how one might build a form in a vanilla Rails project.