ngx-schema-form
ngx-schema-form copied to clipboard
Adding fields to object
Can we achieve the following example? This is a simple one but it should be capable of handling more complex scenarios.
Given a schema like:
{"type":"object", "additionalProperties": {"type": "object", "properties": {"a": {"type":"string"}, "b": {"type": "number"}}}}
Could we have a button and an input in the object widget for adding properties like te ones defined in additionalProperties (one string input for "a" and one number input for "b").
I think you should create a custom widget for this.
How would that widget work? Which methods will it call to modify the model so that new sub-widgets are instantiated?
@rgzr What kind of layout are you trying to accomplish? You can use the array type to add additional fields or widgets e.g.
https://i.imgur.com/EDelEC3.jpg
http://jsonformatter.org/ef5a2e
I'm using angular2-schema-form to allow users to produce a JSON that will be sent to a device that needs a JSON format file to work. I wrote a JSON schema describing the valid configurations that this schema can accept, which includes objects with arbitrary keys whose values can be one of multiple provided complex objects.
@GFoley83 with the example you give me I can only add string values to the array. What if the accepted values for the array are string and number? What if the accepted value is an object with properties? In any case, I need to add ANY type of value (given a JSON schema in an additionalProperties) including complex objects with properties, with the user provided key to an object. It will be great to allow the use of oneOf to offer the user the type of property to add to the object.