0

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.

Bamme
  • 45
  • 1
  • 5

1 Answers1

0

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.

Bamme
  • 45
  • 1
  • 5