Description
Steps to reproduce
Steps:
- Open this link to live example: (required) https://codesandbox.io/p/sandbox/reverent-cori-sk85rc?file=%2Fsrc%2FDemo.js%3A17%2C51
Current behavior
load countries data and get label of country to display in TextField and set it as TextField value
Expected behavior
I need to get country code instead label of it
Example:
when i select "Australia" country, i want when submit form, get code of country "AU"
Context
I understand TextField act like input html and input html only display the value of it
for fixe this issue can use <input type="hidden" name="country" value="AU" />
but i only open this issue if mui handle this situation, i use easy way instead hard way
Your environment
{
"dependencies": {
"@emotion/react": "latest",
"@emotion/styled": "latest",
"@mui/material": "latest",
"react": "latest",
"react-dom": "latest"
},
"description": "https://github.com/mui/material-ui/blob/v6.4.1/docs/data/material/components/autocomplete/CountrySelect.js",
"devDependencies": {
"react-scripts": "latest"
},
"scripts": {
"build": "react-scripts build",
"eject": "react-scripts eject",
"start": "react-scripts start",
"test": "react-scripts test"
}
}
Search keywords: MUI AutoComplete,Different Label And Value