在Redux Form中使用MUI自动完成组件

时间:2020-02-09 17:40:31

标签: reactjs material-ui redux-form

我正在努力尝试在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表单?

0 个答案:

没有答案