Reputation: 131
I want to make a value pre-selected on the drop-down list on this material UI Autocomplete component, it is on the update details page, how do I make it? here is my code below
<FormControl variant="outlined" fullWidth>
<Autocomplete
id="combo-box-demo"
options={props.options}
getOptionLabel={option => option.label}
onChange={(event, newValue) => {
if (props.selectedValue) props.selectedValue(newValue);
if (props.getvalue) props.getvalue(newValue.id);
}}
renderInput={params => (
<TextField
{...params}
size="small"
variant="outlined"
className="formField"
name={props.name}
inputRef={props.register}
/>
)}
/>
</FormControl>
Upvotes: 0
Views: 550
Reputation: 441
Add placeholder to TextField like :
<TextField
{...params}
placeholder ={ "The value that you want to set as preselected" }
size="small"
variant="outlined"
className="formField"
name={props.name}
inputRef={props.register}
/>
Upvotes: 1