我正在努力尝试在redux表单中添加自动完成字段,并且像在其他字段类型中一样,提交表单时能够获得字段输入值。
当前,我的表单由2个字段组成:
<Field name="name" label="Título del servicio" component={renderInput} autoComplete="title"/>
<Field name="address" label="Dirección" component={renderAddressInput} autoComplete="address-line1"/>
“名称”命名字段运行良好,当handleSubmit函数被触发时,我可以控制其值。
但“地址”字段不是。字段组件如下所示:
const renderAddressInput = ({input, label, meta, ...others}) =>{
return(
<div>
<Autocomplete
id="combo-box-demo"
options={top100Films}
getOptionLabel={option => option.title}
renderInput={params =>{
return (
<TextField {...params} label={label} variant="outlined" fullWidth />
)}}
/>
</div>
);
};
我已从MUI Autocomplete documentation中获取了以前的自动完成组件代码。但是,当我在填写表单值后对其进行控制台时,我得到:
{name: "Test"}
如何将“自动完成字段”值链接到我的Redux表单?