question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

form field value as a plain object?

See original GitHub issue

At 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:closed
  • Created 4 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
bluebill1049commented, Feb 8, 2021
1reaction
rpmonteirocommented, Sep 1, 2019

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! 👍

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found