json-schema-form/angular-schema-form

Problems with model binding when using nested Arrays

elbunuelo opened this issue · 5 comments

I'm currently using schema form version 0.8.12 with schema form bootstrap version 0.2.0 and I'm trying to use two nested arrays, however the second level array field values end up appearing as [Object object].

I traced back the error to the keyRedaction state attribute inside the array builder (https://github.com/Textalk/angular-schema-form/blob/0.8.12/src/services/builder.js#L136).

From my point of view, the problem is that the keyRedaction from the parent array is carried over to the child array, which causes the key to be an empty array inside the ngModel builder (https://github.com/Textalk/angular-schema-form/blob/0.8.12/src/services/builder.js#L31).

By changing line 136 inside builder.js from state.keyRedaction = state.keyRedaction || 0; to state.keyRedaction = 0; (i.e. resetting the keyRedaction with each nested array), I was able to get it to work properly, but I'm not sure what other repercussions can that change have in the rest of the code.

What do you think about it?

@elbunuelo I've just started to manage the project and would like to thank you for providing a solution in the issue you have raised, it seems to be working for a lot of people, I will see about getting it in the next update.

Well, this makes me really happy. If it's all right, I'd like to submit a pull request for the fix

By all means :)

finally i will be able to remove the manually override from the plugin xD

A PR has been merged for the issue, please test the solution is resolved and re-open if it is not.