Reputation: 31
we are using angular-schema-from for redring form from json schema and json from
Some how we are not getting default value for enum,
Please refer below form and schema...
Schema json:
{
"type": "object",
"title": "Comment",
"properties": {
"contactDetails": {
"title": "Contact Person",
"type": "array",
"minItems": 1,
"items": {
"type": "object",
"properties": {
"contactType": {
"title": "Contact Type",
"description": "Select",
"type": "string",
"default": "test",
"enum": ["test", "test1"]
}
}
}
}
}
}
Form json:
[
"contactDetails[].contactType",
{
"type": "submit",
"style": "btn-info",
"title": "OK"
}
]
Upvotes: 1
Views: 2529
Reputation: 476
It's because of the array in combo with your form definition, you can't access a field inside an array without wrapping it in a a array type.
Try this form definition instead:
[
{
"type": "array",
"key": "contactDetails",
"items": [
"contactDetails[].contactType"
]
},
{
"type": "submit",
"style": "btn-info",
"title": "OK"
}
]
Example: http://schemaform.io/examples/bootstrap-example.html#/c0cf38b387b84e567176
Upvotes: 2