Checkboxes binding #18297
Unanswered
maduchesne81-cmd
asked this question in
Q&A
Checkboxes binding
#18297
Replies: 2 comments
|
have you tried asp-for tag helper? checkbox it's only sending value when it is checked, if you will use asp-for tag helper it will generate hidden input with value "false", if you don't want to use tag helpers, just add hidden input with same name and type, and with value false |
0 replies
|
I already did something similar in the |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hello,
I have a controller with GET and POST to handle a module to save a message and a checkbox value into the db... for the text its working fine but i cant make it work for the checkbox, like the value is never bound.
<div class="form-check mb-3"> <!-- hidden input ensures unchecked posts false --> <input type="hidden" name="IsEnabled" value="false" /> <!-- checkbox posts true when checked --> <input type="checkbox" name="IsEnabled" id="IsEnabled" class="form-check-input" value="true" @(Model.IsEnabled == true ? "checked" : "") /> <label class="form-check-label" for="IsEnabled">Enable Banner</label> </div>Do I need the hidden one?
Do I need the asp-for?
Im logging the checkbox value first line in the POST and it never changes... my DTO has a nullable bool
what am I missing?? Orchard core 2.1.8
thank for the help
All reactions