I read the docs about formio.js on github. But I can't see how to get json text after the form is build.
Here's my code:
<div id='builder'></div>
<script type='text/javascript'>
var builder = Formio.builder(document.getElementById('builder'), {}, {});
builder.then(function(form){
form.on("change", function(e){
console.log("Something changed on the form builder");
});
});
</script>
Now I want to take the json schema of the form to store in database.
try something like:
...
form.on("change", function(e){
console.log("Something changed on the form builder");
var jsonSchema = JSON.stringify(form.submission, null, 4);
console.log(jsonSchema); // this is the json schema of form components
});
...
or you could try using builder.instance.schema
, as
...
form.on("change", function(e){
console.log("Something changed on the form builder");
var jsonSchema = JSON.stringify(builder.instance.schema, null, 4);
console.log(jsonSchema);
});
...