guillotinaweb / ngx-schema-form

HTML form generation based on JSON Schema
MIT License
485 stars 173 forks source link

Display form data from an array of objects #200

Open dlaugh14 opened 6 years ago

dlaugh14 commented 6 years ago

Schema - { "type": "object", "title": "Types", "properties": { "termsAndConditions": { "type": "array", "items": [ { "type": "object", "properties": { "choice": { "type": "boolean", "title": "I agree to receive an autodialed call from an agent who can help me schedule my service installation:", "enum": [ true ] } }, "required": [ "choice" ] }, { "type": "object", "properties": { "choice": { "type": "boolean", "title": "Second agreement" } }, "required": [ "choice" ] } ], "minItems": 2, "maxItems": 2 } }, "required": [ "termsAndConditions" ] };

This schema seems to come back as a button. We're considering using this library, but our team needs to be able to dynamically insert data into the schema via an array. Is it possible to get this to display or what changes need to be made. The above example would be two agreement checkboxes.

WhileTrueEndWhile commented 6 years ago

The items object should not be an array. This schema is not correct.

Did you mean the oneOf array? In this case, take a look at this issue: https://github.com/makinacorpus/angular2-schema-form/issues/198

acazau commented 6 years ago

That schema is valid array tuple, as per https://json-schema.org/understanding-json-schema/reference/array.html?highlight=tuple#tuple-validation

Facing the same problem with a similar schema.

WhileTrueEndWhile commented 6 years ago

Many thanks for the correction, especially after this long time! The question is now rather whether this is supported...