简体   繁体   English

使用 React-redux-form 只读输入字段

[英]Input field read-only using React-redux-form

Having trouble creating a writable input field as so.在创建可写输入字段时遇到问题。

import { Control } from "react-redux-form";
import { FormControl } from "react-bootstrap";

const existingItem = {
    name: "John",
    city: "Oakland",
};

<Control
    component={FormControl}
    model=".defaultItem"
    componentClass="input"
    id="original-item"
    value={existingItem.name}
/>

My goal is to display an input field with the existingItem.name in it so I can edit and submit.我的目标是显示一个包含 existingItem.name 的输入字段,以便我可以编辑和提交。

However using the value prop the input field becomes read-only.但是使用value prop 输入字段变为只读。 Usually I use defaultValue for this but in this case defaultValue renders the input field writeable but empty.通常我为此使用defaultValue但在这种情况下defaultValue呈现输入字段可写但为空。

您的商店中很可能不存在.defaultItem

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM