add support for flat name for dot notation
See original GitHub issueIs your feature request related to a problem? Please describe.
To avoid mapping between form and api requests, sometimes I want my key as a flat string with dot notation, and not to be automatically converted to nested objects.
Describe the solution you’d like
To trigger or avoid automatically parsing or nesting dot notation in name
, use some way to tell parser to ignore nesting the dot notation, perhaps wrap with quotes:
name="\"object.nested.db.filter.status.value\""
error={errors["\"object.nested.db.filter.status.value\""]}
helperText={errors["\"object.nested.db.filter.status.value\""]?.message}
EDIT: Use escaped double quotes to show how it would work better.
The dot notation could ignore automatically nesting because it contains or starts and ends with quotes '
or "
.
Describe alternatives you’ve considered
I see that getValues
will return the flat key, but it doesn’t feel right, I’d like to use normal submit handler if possible, but maybe I’m not seeing the right way to use it in this case.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Thanks @kotarella1110 . The types do indeed pass, however the parsed values sent to
onSubmit
is parsed with the'
prepended on first key, and appended to last key – returns values likeIt would be cool if instead of nesting, first checks if it’s a string if it contains
'
(or some other way of telling RHF not to automaticallytransformToNestObject
) and returns flat:Not sure if thats very intuitive or maybe too hacky even. I am just going to close this ticket.
@ilovett Thanks for your suggestion. Because TS cannot parse the string literal type, this suggestion can cause to the following type error: