json-schema-form / angular-schema-form

Generate forms from a JSON schema, with AngularJS!
https://json-schema-form.github.io/angular-schema-form
MIT License
2.47k stars 653 forks source link

Wrong key resolving for ngModel in decorator.js #761

Closed senyaak closed 7 years ago

senyaak commented 8 years ago

In https://github.com/json-schema-form/angular-schema-form/blob/development/src/services/decorators.js#L193-L201 the ngModel won't get correct path if the directive will be called in ngRepeat, cause some key(s) well be an empty string. Example we have ['lvl1','array','', 'value'] After resolving we'll get 'model['lvl1']['array']['']['value']' and this isn't right. At this point if the key array contains an empty string, we should use a scope.$index for this key!

zfarrell commented 7 years ago

fyi, i believe the decorators.js link is out of date. I think this represents what @senyaak was linking to at the time this issue was created: https://github.com/json-schema-form/angular-schema-form/blob/0a8702464504cf143c1e7405de3c1e4f25ad4e4f/src/services/decorators.js#L193-L201

@Anthropic i noticed you added the has: PR label, but i don't actually see one. Am i just overlooking it?

Anthropic commented 7 years ago

@zfarrell I have made changes in the webpack-babel branch to ensure the key is available which I believe will fix this issue. If you or @senyaak have any time, a unit test for this would really help me confirm it as fixed.

Anthropic commented 7 years ago

I believe this is fixed in the latest updates (alphas) for the eventual 1.0.0 release.

Please re-open if there are still issues in these versions and please make a plunker or gist to help me.