brutusin / json-forms

JSON Schema to HTML form generator, supporting dynamic subschemas (on the fly resolution). Extensible and customizable library with zero dependencies. Bootstrap add-ons provided
http://brutusin.org/json-forms
Apache License 2.0
606 stars 168 forks source link

Dynamic Schema issues in array #101

Open nagarajanchinnasamy opened 6 years ago

nagarajanchinnasamy commented 6 years ago

When using dependsOn between properties of an object placed in an array, encountered various issues. Please use the examples provided in examples folder to test scenarios below:

Issue 1:

When an item is added by clicking Add Item button, received Uncaught Type Error: element.equals is not a function exception.

01_elementequals

Issue 2:

After fixing issue-1, using the following steps:

  1. Add an item
  2. Remove the item
  3. Add the item again

received Uncaught TypeError: cannot read property 'type' of undefined exception

02_addlevel1item_delete_againadd

Issue 3:

After fixing issue-2, using the following steps (in example2.html):

  1. Add Level-1 Item
  2. Add Level-2 Item
  3. Select "OPTION-2" in drop-down

received Uncaught TypeError: cannot read property '$ref' of undefined exception.

03_addlevel2item_selectoption-2

Issue 4:

After fixing issue-3, noticed that, dependency change is effective only in the last item of the array. Other items do not react to change in the drop-down value. This I feel something to do with depencyMap. But could not figure out a solution for this. Need help. Thanks.

KiSchulte commented 6 years ago

@nagarajanchinnasamy Thank you this pull request fixed all my open issues. @idelvall +1 for merging this pull request

machinaeXphilip commented 6 years ago

thank you! fixed issues i had as well with dynamically build arrays with distinct fieldnames hope this can be merged soon into @idelvall 's master !

ma-hack commented 5 years ago

thank you very much for the implementation!

With the getData method, the generated elements are not displayed. The error occurs when the first element had an addition and the next element makes a schema change.

image

Than getData has the result: data: {"speciesList":[{"species":"dog"},{"species":"human"}]}

With only one Entry the result is: data: {"speciesList":[{"species":"dog","subspecies":"bulldog"}]}

How did you fix the problem? Does it happen to you too?