form field value as a plain object?
See original GitHub issueAt the moment, if you want to keep a plain object as a value in the form, you have to serialize/deserialize it all the time:
*get*
JSON.parse(getValues().someKey))
*set*
setValue('someKey', JSON.stringify(object))
Are there any plans to support just having a plain object as some field values?
An example use-case would be a custom auto-complete component where the user selects some value from a dropdown, but we need to persist the entire object as the value for that field.
Thank you for any help you might provide! 👍
(congratulations on the library. It’s a fantastic and useful piece of code 😃 )
Issue Analytics
- State:
- Created 4 years ago
- Comments:14 (7 by maintainers)
Top Results From Across the Web
How to Convert HTML Form Field Values to a JSON Object
The FormData API doesn't directly convert form values to JSON, but we can get there by using the entries method and passing its...
Read more >Form input to JavaScript Object - Stack Overflow
Add a listener to the form, collect the values, build an object and ... Though I'd be tempted to use a plain button,...
Read more >Convert Form Data to JavaScript Object - Stack Abuse
In this article, we'll take a look at how to easily convert form data into a JavaScript object without installing any unnecessary dependencies....
Read more >Chapter 18 Forms and Form Fields - Eloquent JavaScript
The name attribute of a form field determines the way its value will be identified when the form is submitted. It can also...
Read more >How to Use the FormData Object | JavaScript in Plain English
The JavaScript FormData interface gives us a way to create an object of key-value pairs representing form fields and their values.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
here is an updated CSB: https://codesandbox.io/s/sparkling-haze-fl4wh?file=/src/App.js
Sorry, I couldn’t come to the PC for the past few days. Everything is working fine, thank you! It was a silly oversight on my code that was causing that weird behaviour.
Thank you very much for your help! 👍