Description
Describe the bug
<RadioInput>
does not work because it uses value
attribute instead of checked
.
To Reproduce
Steps to reproduce the behavior:
- Create a component that contains a
RadioInput
that is bound to abool
property (that is set totrue
) - Show Component
- Radio input is not checked
Expected behavior
The radio input's checked state can be bound to a bool value
Versions (please complete the following information):
- .NET Version: .NET 9
- BlazorBootstrap: 3.3.0
- Blazor WebAssembly / Server: WebAssembly
- Blazor Interactive Render Mode: WebAssembly
- Blazor Interactivity Location: n/a
Sample code
<RadioInput @bind-Value="IsOn1" Name="my-group"></RadioInput>
<RadioInput @bind-Value="IsOn2" Name="my-group"></RadioInput>
@code
{
private bool IsOn1 { get; set; } = true;
private bool IsOn2 { get; set; }
}
Additional context
The built-in InputRadio
uses a surrounding InputRadioGroup
and then allows picking from a list of values. While I like the idea of having "standalone" radio buttons as well (like RadioInput
), having a selection of some kind is currently also hard to do.
Similar problems go for CheckboxInput
where the value is not a bool
.
As a workaround, you can add checked=@myProperty
to the RadioInput
to at least get the rendering right. It still doesn't trigger the setter of other radio inputs in the group, though. So cleanup of other items in the group on the model side has to be done manually.