Skip to content
This repository has been archived by the owner on Apr 30, 2018. It is now read-only.

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

Open
kranthitech opened this issue Feb 18, 2016 · 6 comments
Open

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

kranthitech opened this issue Feb 18, 2016 · 6 comments

Comments

@kranthitech
Copy link

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
Copy link
Member

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
Copy link

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

@kentcdodds
Copy link
Member

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
Copy link
Member

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

@hcaloto
Copy link

hcaloto commented Nov 2, 2017

+1

@egucciar
Copy link

@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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants