Hi, I use an Angular 14.30 and JSON Forms 3.0.0,
Can I somehow set the array from backend to my custom dropdown in an Angular json forms?
And the second question: how can I change the enums array when my other control changes its value? (in the schema example: I change flow option from 1 to 2 and in this case my id array should change data)
A part of my schema:
"test": {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "test_types",
"type": "object",
"properties": {
"id": {
"title": "id",
"type": "string",
"enum": [
// dynamic array from server
]
},
"flow": {
"title": "flow",
"type": "string",
"enum": [
"option1",
"option2"
]
}
},
"required": [
"id",
"flow"
],
"additionalProperties": false
},
1 Like
Hi @VladislavLinnik ,
first of all, JsonForms 3.0.0 is pretty old and I recommend to update to a later version. 3.1 is still compatible with Angular 14. For later versions, you already need to update your angular version.
Can I somehow set the array from backend to my custom dropdown in an Angular json forms?
If the array only needs to be fetched once, you could do that before rendering the form and simply add it to the schema.
If you need to update this dynamically however, you need to implement a custom renderer. This renderer could for instance get a custom service injected that provides the enum options. The renderer could then subscribe to changes there.
And the second question: how can I change the enums array when my other control changes its value? (in the schema example: I change flow option from 1 to 2 and in this case my id array should change data)
If you upgrade to JsonForms 3.4, you can use the middleware support for this.
Alternatively you can change your data object - that you hand into jsonforms - manually after getting a relevant change from JSON Forms’s dataChange output.
Kind regards,
Lucas
2 Likes