react-jsonschema-form generate with data

Viewed 1234

I m using react-jsonschema-form generator with NJsonSchema. After submit form i record json output and i want to use form for edit with submitted data any time. But i cannot find a way create the form with submitted data before. After try some json schema updates, I realize, the value keys in json not for filling inputs.

 "Age": {
          "value": "34",
          "type": "integer",
          "format": "int32"
        }

here is react render code :

 render((
  <Form schema={schemaTest}
        uiSchema={uiSchema}
        onChange={log("changed")}
        onSubmit={log("submitted")}
        onError={log("errors")} />
), document.getElementById("app"));

is there any way filling inputs with json data, while form creating.

2 Answers

Try to set the values in states. Then try to put those states to each fields "default" properties.

Eg: "Age": { "value": "34", "type": "integer", "format": "int32", "default":this.state.formdata.age }

Related