Formik Material UI Autocomplete - get string value in options object

173 views Asked by At

I am using the Field component of the formik-material-ui package with the component={Autocomplete} prop and I am trying to set the value to just the string in the object. I prefer not to change the shape of the options={data} prop and instead get the string value instead of the entire object. However, the value of the field itself is abstracted to just the name prop and I'm confused about how to go about manipulating it. One more caveat, I would like the freeSolo property to be set also, so the user can use the autocompleted data or not.

Here is the CURRENT example response WITH an autocomplete option.

{
    "autocomplete" : { "title": "The Shaw Shank Redemption"}
}

Here is the CURRENT example response that is NOT an autocomplete option

{
"autocomplete": ""
}

This is my desired response that is a string.

"autocomplete": "<freeSolo_value>"

OR

"autocomplete": "<option_value>"

I made a Codesandbox for anyone that is willing to help https://codesandbox.io/s/elegant-lichterman-9dfq7?file=/src/index.tsx

Any help or ideas is much appreciated!

0

There are 0 answers