Skip to content

Commit

Permalink
Add demo to prove fix works
Browse files Browse the repository at this point in the history
  • Loading branch information
haacked committed Dec 12, 2023
1 parent a1d2b9e commit 15bdd9a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
6 changes: 6 additions & 0 deletions Controllers/Validations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ public IActionResult CheckRemote(string id)
return Ok(id == "42");
}

[HttpPost]
public IActionResult CheckboxRemote(bool isChecked)
{
return Ok(isChecked);
}

[HttpGet]
public IActionResult Test()
{
Expand Down
4 changes: 2 additions & 2 deletions Pages/Demos/Checkboxes.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
<label>@animal</label>
}
<span asp-validation-for="SelectedAnimals"></span>
@if (Model.SelectedAnimals.Any()) {
<em class="results">Selected animals: @string.Join(", ", Model.SelectedAnimals)</em>
@if (Model.SelectedAnimals!.Any()) {
<em class="results">Selected animals: @string.Join(", ", Model.SelectedAnimals!)</em>
}
</div>

Expand Down
2 changes: 2 additions & 0 deletions Pages/Demos/Checkboxes.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public IActionResult OnPost()

public class InputModel
{
[Remote("CheckboxRemote", "Validations", HttpMethod = "Post")]
public bool IsChecked { get; set; }
}

Expand All @@ -50,6 +51,7 @@ public class InputModel
public class Selectable
{
public required string Name { get; set; }

public bool IsSelected { get; set; }
}
}

0 comments on commit 15bdd9a

Please sign in to comment.