Primeng: Disabling one radioButton in a reactive form directive gives warning

Created on 8 Jan 2021  路  1Comment  路  Source: primefaces/primeng

I'm submitting a ... (check one with "x")

[x] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35

Current behavior
The only way to disable a single radio in Angular currently is to set it on the radioButton itself. I can't set it on the control object. But:

<p-radioButton name="a" value="a" formControlName="ctrl"/>
<p-radioButton name="b" value="b" formControlName="ctrl" [disabled]="true"/>

Gives warning:

It looks like you're using the disabled attribute with a reactive form directive. If you set disabled to true
when you set up this control in your component class, the disabled attribute will actually be set in the DOM for
you. We recommend using this approach to avoid 'changed after checked' errors.

Example:
form = new FormGroup({
first: new FormControl({value: 'Nancy', disabled: true}, Validators.required),
last: new FormControl('Drew', Validators.required)
});

Expected behavior
No warning

What is the motivation / use case for changing the behavior?
I don't like warnings.

  • Angular version: 9.1.12

  • PrimeNG version: 11.1.0-rc.1

  • Browser: all

  • Language: all

pending-review

Most helpful comment

I hope this time it isn't immediately closed again like https://github.com/primefaces/primeng/issues/9143. I tried [attr.disabled] but that is ignored by p-radioButton.

>All comments

I hope this time it isn't immediately closed again like https://github.com/primefaces/primeng/issues/9143. I tried [attr.disabled] but that is ignored by p-radioButton.

Was this page helpful?
0 / 5 - 0 ratings