如何在tcomb-form-native中为inputText添加值?

时间:2018-04-24 14:41:17

标签: forms react-native tcomb-form-native tcomb

我是本土的新手,我使用tcomb-form库为我的应用程序创建表单。 我想为我的某些字段添加默认值,这意味着它们首次出现时默认情况下必须具有值。 这是我到目前为止所尝试的但是该字段仍然显示为空:

this.Position = t.struct({
      PosName: FormFields.String,
    });
fields:{
PosName: {
          placeholder: "Name der Position",
          error: "Dieses Feld ist erforderlich",
          label: "Name der Position",
          value: "some text here ",
          template: Template
        },
//... other fields here
}

1 个答案:

答案 0 :(得分:2)

您可以使用字段和默认值创建对象,然后将其传递给表单元素,如下所示:

<Form type={this.Position} value={value}

然后在你的渲染上:

{{1}}

以下是文档:tcomb-form-native default values