Select value as object instead of string #6209
-
Hey guys, is there any way to put select option value as an object (for example {name: 'John', age: 35}) and obtain it in data object upon submit? I try to pass object but get "[Object Object]" as a result in submitted data. this is what expected: <option value={name: 'John', age: 35}> John </option> |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
you will have to build a controlled component and wrapped with Controller, native input only support select as |
Beta Was this translation helpful? Give feedback.
-
Hi, Do you have an example for this? I am able to do that using a custom Controlled component built with MUI. However I wonder if this is OK or not in term of performance. Regards, Samuel |
Beta Was this translation helpful? Give feedback.
you will have to build a controlled component and wrapped with Controller, native input only support select as
string
, you can consider to custom component likereact-select