|
9 | 9 | <span tabindex="0" class="@IconClassname"> |
10 | 10 | <input id="@($"static-radio-{_elementId}")" tabindex="-1" @attributes="UserAttributes" type="radio" role="radio" |
11 | 11 | class="mud-radio-input static-radio-input" checked="@_isChecked" disabled="@GetDisabledState()" name="@(_isChecked ? ParentGroup?.GroupName : "")" value="@Value" |
12 | | - aria-checked="@(_isChecked.ToString().ToLower())" aria-disabled="@(GetDisabledState().ToString().ToLower())" @onclick:preventDefault="@GetReadOnlyState()" /> |
13 | | - <MudIcon Icon="@(ParentGroup.CheckedIcon ?? CheckedIcon)" Color="HasErrors ? Color.Error : ParentGroup?.Color ?? this.Color" Size="@Size" Disabled="@Disabled" |
| 12 | + aria-checked="@(_isChecked.ToString().ToLower())" aria-disabled="@(GetDisabledState().ToString().ToLower())" @onclick:preventDefault="@GetReadOnlyState()" |
| 13 | + data-value="@Value" data-group-name="@ParentGroup?.GroupName" /> |
| 14 | + <MudIcon Icon="@(ParentGroup?.CheckedIcon ?? CheckedIcon)" Color="HasErrors? Color.Error: ParentGroup?.Color ?? this.Color" Size="@Size" Disabled="@Disabled" |
14 | 15 | id="@($"radio-checked-icon-{_elementId}")" style="@($"display: {_checkedStyle}")" /> |
15 | | - <MudIcon Icon="@(ParentGroup.UncheckedIcon ?? UncheckedIcon)" Color="HasErrors ? Color.Error : ParentGroup?.UncheckedColor ?? this.UncheckedColor ?? Color.Inherit" |
| 16 | + <MudIcon Icon="@(ParentGroup?.UncheckedIcon ?? UncheckedIcon)" Color="HasErrors ? Color.Error: ParentGroup?.UncheckedColor ?? this.UncheckedColor ?? Color.Inherit" |
16 | 17 | Size="@Size" Disabled="@Disabled" id="@($"radio-unchecked-icon-{_elementId}")" style="@($"display: {_uncheckedStyle}")" /> |
17 | 18 | </span> |
18 | 19 | @if (!string.IsNullOrEmpty(Label)) |
|
67 | 68 | const parentContainer = radio.closest("[role='radiogroup']"); |
68 | 69 | if (!parentContainer) return; |
69 | 70 |
|
| 71 | + const hiddenInput = parentContainer.querySelector("input[type='hidden']"); |
| 72 | + const selectedValue = radio.getAttribute('data-value'); |
| 73 | + const groupName = radio.getAttribute('data-group-name'); |
| 74 | +
|
70 | 75 | parentContainer.querySelectorAll('.static-radio-input').forEach(function (r) { |
71 | 76 | if (r !== radio) { |
72 | 77 | r.checked = false; |
|
84 | 89 | uncheckedIcon.style.display = 'none'; |
85 | 90 | r.setAttribute("checked", true); |
86 | 91 | r.setAttribute("aria-checked", true); |
87 | | - r.setAttribute("name", "@ParentGroup?.GroupName"); |
| 92 | + r.setAttribute("name", groupName); |
| 93 | + // Update the hidden input value |
| 94 | + if (hiddenInput) { |
| 95 | + hiddenInput.value = selectedValue; |
| 96 | + hiddenInput.setAttribute("value", selectedValue); |
| 97 | + } |
88 | 98 | } else { |
89 | 99 | checkedIcon.style.display = 'none'; |
90 | 100 | uncheckedIcon.style.display = 'block'; |
|
0 commit comments