Has anyone managed to create custom widgets and layouts for form controls using angular2-json-schema-form? I cannot find links to any documentation or examples.
Asked
Active
Viewed 1,638 times
4
-
Did you by any chance figure this out? I'm in desperate need of this actually working. – sjjk001 Oct 07 '20 at 12:00
-
1@sjjk001 you can check out my sandbox here https://github.com/neil-coutinho/json-form-ajsf custom widgets are just like any other components. You can override existing layout controls with your widgets – Neil Oct 08 '20 at 06:42
-
This has been very helpful, thank you so much! – sjjk001 Oct 08 '20 at 08:11
-
Thanks. Note I have used https://github.com/hamzahamidi/ajsf's updated version. angular2-json-schema-form has not been maintained in a while. – Neil Oct 08 '20 at 08:31
-
I have this particular problem, I'm trying to create a widget for a property type object on the schema, but when I do it like in our example the 'this.jsf.initializrControl(this)' throws the following error 'core.js:4197 ERROR TypeError: control.registerOnChange is not a function', do you have any ideas what I could be doing wrong? – sjjk001 Oct 12 '20 at 08:32
-
1Do you have a repo or an example where I can take a look? – Neil Oct 13 '20 at 06:17
-
I have figured it out yesterday, what worked for me was making a widget for the object but not initializing the control from that widget component but making another widget for the object properties, binding layoutNode.items['property'], layoutIndex and dataIndex to the other widget component and initializing the control from the object widget, works like a charm. Thank you anyway though @Neil :) – sjjk001 Oct 13 '20 at 08:39
1 Answers
1
In their documentation it indicates that you can create your own json-schema-form components/widgets and pass a mapping of them to the json-schema-form directive, thereby either creating your own form controls or overriding the defaults.
Here is the source for the TEXTAREA component/widget as a reference for how to create your own form control.

0x6563
- 1,032
- 10
- 17

Nuri Hodges
- 868
- 6
- 13
-
Yes, Thank you. I did check it out. Unfortunately they do not have a working example. – Neil Mar 03 '18 at 17:23