Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array of Raw Objects doesn't work #3

Open
aamccaslin opened this issue Feb 7, 2018 · 3 comments
Open

Array of Raw Objects doesn't work #3

aamccaslin opened this issue Feb 7, 2018 · 3 comments
Labels
Milestone

Comments

@aamccaslin
Copy link

An array of raw objects doesn't update the model correctly.

@aamccaslin
Copy link
Author

aamccaslin commented Feb 7, 2018

Looking at the generated HTML ng-model="item" for the raw-object node inside an array, which is clearly wrong. For reference, a string node looks like ng-model="modelArray[$index]"

I think this has to do with how the builders are getting applied. In angular-schema-form sf-builder.provider.js the ngModel builder is doing something special when in an array. There's also this comment,
// Another builder, i.e. array has overridden the modelValue

@aamccaslin
Copy link
Author

sf-builder.provider.js line 169:

// Special Case, an array with just one item in it that is not an object
// So then we just override the modelValue
if (args.form.schema && args.form.schema.items &&
    args.form.schema.items.type &&
    args.form.schema.items.type.indexOf('object') === -1 &&
    args.form.schema.items.type.indexOf('array') === -1) {
    var strKey = sfPathProvider.stringify(args.form.key).replace(/''/g, '"') + '[$index]';
    state.modelValue = 'modelArray[$index]';
  } else {
    state.modelName = 'item';
  }

So it seems like if this wasn't object would it work? But I know we have (non-raw) objects arrays elsewhere...

@aamccaslin
Copy link
Author

Looks like it's working correctly in ASF demo app, just need to verify it's working in Beergarden.

It's almost fixed, but there's still the Invalid Type, expected ["array", "null"] text that's display. You can still submit successfully (since we specifically ignore that error) but it's a little weird.

I think I can fix this to only display an error message if it's an actualy error but probably not worth moving off backlog,

@aamccaslin aamccaslin added the asf label Feb 7, 2018
@aamccaslin aamccaslin added this to the backlog milestone Feb 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant