-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
Radio Buttons in a Form Array affect all Radio Buttons in the Array #9723
Comments
I have the same problem ☝️. Does someone know solve this? Please, It's urgent |
@AlbaSS18 I have not found one, other than don't upgrade to PrimeNG 11. Given that the |
+1 here, it's unusable inside Form Arrays, please fix |
Is there any news on the resolution of this bug? The component is absolutely unusable.... |
Or when it's planned to solve it |
Any update regarding this issue? |
I am also encountering this problem, any updates? |
I'm having the same issue. Any suggested workarounds? |
I ended up re-factoring our implementation to use a ngForEach which adds the index to the name (ie radio-buttons-1). Then when I build up the form control I create the property names for each object as such and undo the same on submit. I hated having to add the code to do this but it was what was needed to upgrade the framework and not be stuck on an old version as it seems this is not likely to be fixed or get any other attention from PrimeFaces right now without purchasing a support agreement. |
I temporarily ended up implementing it the native way and just aligning the style with primeng as I've implemented their radio buttons in other parts of our project and don't want the trouble of replacing them all. |
This seems a lot like #9162 rearing its ugly head again, except now for some reason I haven't had the time to discover, the workaround by setting the value with emitEvent as false in a valueChanges subscription isn't working anymore. |
The same issue with version 12.2.1 |
Any news please about this issue? is there a soon fix or a workarround? |
Using version V11-LTS and still doesn't work due to the checkName() function (https://github.com/primefaces/primeng/blob/11.4.5/src/app/components/radiobutton/radiobutton.ts#L185) of p-radioButton. Workaround here was to use |
Was facing the same issue with template driven forms in Angular. |
Hi, So sorry for the delayed response! Improvements have been made to many components recently, both in terms of performance and enhancement. Therefore, this improvement may have been developed in another issue ticket without realizing it. You can check this in the documentation. If there is no improvement on this, can you reopen the issue so we can include it in our roadmap? Best Regards, |
@acgritt can You please verify it? I think it still exists in 14.2.1 version |
Thanks. working fine with native radio input. |
Here is my reproduction with PrimeNG 13 and FormGroup rather than FormArray: Note that just using HTML input radio and Angular RadioControlValueAccessor works correctly. (This is forked from the stackblitz from PrimeNG RadioButton, which is still using PrimeNG 13 rather than latest PrimeNG 15.) |
Absolutely the same problem for 15.2.0
it affects all radioButtons with the same value for all groups inside formArray P.S. But value for formArray binds okay. I don't know why, but only click not working correctly (selects all radios, not only the clicked one) |
I finally came up with fix) The fix is:
If you have some problems with types (AbstractControl instead of FormGroup/FormControl) - create dumb pipe, like
and use it)
Have a nice day) |
The same issue with version 15.4.1 |
Issue still exists :( |
We are experimenting the same issue. |
"data" is the name of the FormArray "type" is the name of the radio FormControl <ng-container *ngFor="let row of data.controls; let i = index" [formGroupName]="i"> the name needs to be the same for the same control and all the inputIds have to be unique; |
Same issue here :( |
This issue is still reproduced with version 16 |
you need an unique inputId attribute on every radio but the same form control (name) on all and it will work! |
Sadly, yes, but the pipe described by @Tilesto works most of the time |
Thank you! It trully hellpes to resolve this issue! |
Instead of using the FormControlPipe, I think it's better to use |
I'm submitting a ... (check one with "x")
Current behavior
Selecting a radio button in one group of a Form Array causes all other radio buttons in other groups to change their value selections. As this is a Form Array all the formControlName values for the radio buttons are the same.
Expected behavior
When selecting a radio button in one group in a Form Array it should have no impact on the radio buttons in another group.
Minimal reproduction of the problem with instructions
https://stackblitz.com/edit/primeng-radio-form-array-selection-issue
What is the motivation / use case for changing the behavior?
I should be able to dynamically render questions in a Form Array with radio buttons. This was working for Angular 10 but is not in Angular 11.
Please tell us about your environment:
Windows 10
Angular 10
PrimeNG 11
VS Code
.NET 3.1
Browser: all
Language: TypeScript 4.0.5 | ES6/7
Node (for AoT issues):
node --version
= v12.19.0The text was updated successfully, but these errors were encountered: