我在github上阅读了关于formio.js的文档。但是我不知道如何在构建表单后获得json文本。
下面是我的代码:
<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>现在,我想将表单的json模式存储在数据库中。
发布于 2020-03-19 17:16:47
尝试如下所示:
...
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
});
...或者你可以尝试使用builder.instance.schema,就像...
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);
});
...发布于 2020-07-03 17:28:10
我知道这已经解决了问题,但是对于那些仍然想使用Formio.builder而不是new Formio.FormBuilder的人,你可以尝试这样做:
Formio.builder(document.getElementById('builder'), {}).then(function(form){
form.on("change", function(e){
console.log(form.schema);
});
});https://stackoverflow.com/questions/60753881
复制相似问题