Hamza Khanzada
Hamza Khanzada

Reputation: 1529

How to generate form back from JSON Schema in form builder

I am using Form.io's Formbuilder, I have built a form using the Formbuilder's drag and drop functionality and I have saved the generated JSON Schema into my database. How can I reconstruct the form builder again with the same controls from JSON Schema?

I want to do this so that the user can make any modifications to the created form.

I am looking for how to reinitialize the form builder back from JSON.

JSON was generated from the form builder's builder.instance.schema.

Upvotes: 2

Views: 2378

Answers (1)

Hamza Khanzada
Hamza Khanzada

Reputation: 1529

I was able to to load the form back by passing the json schema to Formio.builder. I was using vanilla javascript. All credits to @randallknutson's Github reply.

//JSON Schema loaded from database
const createdForm = {
display: 'form',
components: [],
...
}

Formio.FormBuilder(document.getElementById('builder'), createdForm, options);

Upvotes: 3

Related Questions