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

bug: group nested radios not working #205

Closed
paullryan opened this issue Nov 14, 2016 · 3 comments
Closed

bug: group nested radios not working #205

paullryan opened this issue Nov 14, 2016 · 3 comments
Labels

Comments

@paullryan
Copy link
Contributor

If you next radios inside different groups with different parents given that angular2-mdl is using checkboxes all groups sub radios are linked. This can cause odd and unintended side-effects with models that rely on nesting such as arrays of objects.

Steps to reproduce

  1. Create a form with with two formgroups like
<form [formGroup]="form">
  <div formGroupName="group1">
    <mdl-radio formControlName="type" value="type1">
    <mdl-radio formControlName="type" value="type2">
  </div>
  <div formGroupName="group2">
    <mdl-radio formControlName="type" value="type1">
    <mdl-radio formControlName="type" value="type2">
  </div>
</form>
  1. Create the corresponding form model
...
new FormGroup({
  group1: new FormGroup({
    type: new FormControl('')
  }),
  group2: new FormGroup({
    type: new FormControl('')
  })
});
...

This should result in a model of

{
  group1: {type: 'type1'}
  group2: {type: 'type2'}
}

however the boxes are being tied to each other. Not sure how to fix this one yet, however I'll think on it.

@paullryan
Copy link
Contributor Author

Side note, when I switch to using radio buttons directly this works beautifully.

@mseemann
Copy link
Owner

Will have a look...

@mseemann
Copy link
Owner

i have created a pr (#209) that uses the formGroupName as additional information to decide which radio buttons have to be deselected. just if you want to have a look...

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

2 participants