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

array of strings with enum #969

Closed goliwok closed 6 years ago

goliwok commented 6 years ago

Hi,

I have the following properties in my schema :

"services": { "type": "array", "items": { "type": "object", "title": "services", "properties": { "name": { "title": "services", "type": "string", "enum": [ "influx", "netdata", "jenkins", "john", "valgrind" ] }, "required": [ "name" ] }, } },

how can i change it in array of strings ? This is current result sample in json: {"services":[{"name":"jenkins"},{"name":"john"}]

What i want to get:

"services":["jenkins","john"]

i have already tried this, without succed :

"linux_services": { "type": "array", "title": "linux_services", "items": { "type": "string", "title": "linux_services", "enum": [ "influx", "netdata", "jenkins", "john", "valgrind" ] } },

any ideas ?

thanks you !

Anthropic commented 6 years ago

@UtsukushiiBushido the easiest way would be using checkboxes if the list is finite see the titleMap examples.

If not then it is harder to accomplish without using something like the calculate addon to process fields into a single array.

Please comment if you want to re-open or do not feel the question has been answered sufficiently.