json-schema-form / angular-schema-form

Generate forms from a JSON schema, with AngularJS!
https://json-schema-form.github.io/angular-schema-form
MIT License
2.47k stars 653 forks source link

Why schema is not rendered when properties.length is 0 #971

Closed MGouaillier4CT closed 6 years ago

MGouaillier4CT commented 6 years ago

As i use ASF in my project, i sometimes wish to render forms that don't have any properties. I was wondering why my form was never rendered and i came across this condition :

if (form && schema && schema.type && 
    (lastDigest.form !== form || lastDigest.schema !== schema) && 
    Object.keys(schema.properties).length > 0) {
        lastDigest.schema = schema;
        lastDigest.form = form;

        render(schema, form);
}

Is there a particular reason why a form need at least one property ?

Anthropic commented 6 years ago

@MGouaillier That's the schema property object and no it doesn't.

It shouldn't be required in the alphas already, it has been commented out in the code and I will most likely remove it once I finish the bit below it. https://github.com/json-schema-form/angular-schema-form/blob/development/src/directives/sf-schema.directive.js#L199