formly-js / angular-formly-templates-bootstrap

Angular-Formly: Bootstrap Templates
http://formly-js.github.io/angular-formly
MIT License
110 stars 81 forks source link

multiCheckbox with a key in a nested json model does not work #88

Open kranthitech opened 8 years ago

kranthitech commented 8 years ago

Noticed an error with multi select.

If the key is of the form "model", it works fine and the model is bound to an array based on the selected checkboxes But when key is of the form "model.something", it gets bound to a boolean instead of an array, and all the checkboxes get selected or de-selected at once.

kentcdodds commented 8 years ago

Could you please reproduce your issue using issue.angular-formly.com? It will help us determine what exactly the problem is that you're describing and how it could be fixed. Thanks!

ankitprahladsoni commented 8 years ago

Hi @kentcdodds , I have tried to reproduce the same issue. http://jsbin.com/pazotafewe/edit?js,output

kentcdodds commented 8 years ago

Ah, yeah, here's the problem:

  1. When you provide a key that's nested this code runs to replace any instance of ng-model in the template with 'model.' + options.key.
  2. With this template the ng-model needs to actually remain the same.

So I suggest that we add a value in extras of fields to disable/control (via a function) the manipulation of nested keys and then utilize that in the defaultOptions of this type.

Feel free to makeapullrequest.com!

kentcdodds commented 8 years ago

Note: This will take work in both this repo and the formly core repo.

hcaloto commented 7 years ago

+1

egucciar commented 6 years ago

@hcaloto

i resolved this issue on my local enviroment. I had to make some adjustments in formlyCore to accomodate the use case, as well as modifying the multiCheckbox controller.