I have a form.io builder initialized like
window.onload = function() {
Formio.icons = 'fontawesome';
Formio.builder(document.getElementById('builder'), schema ? JSON.parse(schema) : {}).then(function(builder) {
changeJson(builder.schema);
builder.on('change', function() {
changeJson(builder.schema);
});
builder.on('submit', function() {
return false;
});
});
};
The above code opens a form.io builder. I want a default field like email added to the builder and this field should not be allowed to be deleted.
Please advise.
I figured out this
You can set the schema like
$default_schema_email = "{\"components\":[{\"label\":\"Enter Your Email\",\"tableView\":true,\"validate\":{\"required\":true},\"type\":\"email\",\"input\":true,\"key\":\"email\"},{\"type\":\"button\",\"label\":\"Submit\",\"key\":\"submit\",\"disableOnInvalid\":true,\"input\":true,\"tableView\":false}]}";
var schema = @json($default_schema_email);
The above initialization will add an email field to the builder.