Hi,
I have this code here inside the form and only code for the switch(), :
<div class="create-section">
@(
Html.Kendo().Form<WeighmoreSouth32Web.Models.Role>()
.Name("createForm")
.HtmlAttributes(new { action = "Create", method = "POST" })
.Validatable(v =>
{
v.ValidateOnBlur(true);
v.ValidationSummary(vs => vs.Enable(true).TemplateId("validation-message"));
})
.Items(itemGroup =>
{
itemGroup.AddGroup().Layout("grid").Grid(g => g.Cols(3).Gutter(20)).Label("Role Info").Items(items =>
{
items.Add()
.Field(f => f.RoleName)
.Label(l => l.Text("Role Name"));
items.Add()
.Editor(e => e.Switch().Name("AddCustomer")).Field(f => f.AddCustomer)
.Label(l => l.Text("Role Name*:"));
});
})
)
</div>
it is working fine for the textbox input but when I use switch to pass the true value it is passing it two times one true and other one false. But it does not do the same when switch is off, only passes the false value. Here is a picture of it. I did also tried some Js/Jquery code to bind it but it didn't worked as well. Please help.
Hi Rikki,
I made a couple of tests locally and assume that we are speaking about the hidden input field that is generating for the boolean fields by default.
https://stackoverflow.com/questions/2697299/asp-net-mvc-why-is-html-checkbox-generating-an-additional-hidden-input
This behavior is expected and actually, the value received in the Action Method of the Controller is the correct one.
I hope this information helps.
If any further assistance or information is needed, do not hesitate to contact me and the team.
Kind Regards,
Anton Mironov