-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Labels
BugC: CheckboxFP: CompletedSync status with associated Feedback ItemSync status with associated Feedback ItemRegressionBroken functionality which was working previouslyBroken functionality which was working previouslyS: Wrappers (ASP.NET Core)S: Wrappers (ASP.NET MVC)SEV: High
Milestone
Description
Bug report
Checkboxes for non-nullable booleans fail validation when generated using @(Html.CheckBox() or @(Html.CheckBoxFor(m => m)
Related to #7798
Reproduction of the problem
Model:
public bool Shipped { get; set; }
Implement an editable Grid and use a Boolean template for an editor where @(Html.CheckBoxFor(m => m) is used.
Current behavior
Upon saving the checkbox validation fails.
Expected/desired behavior
Validation shall succeed.
Workarounds
- Use a nullable bool if the checkbox should not be validated -
public bool? Shipped { get; set; }or - Use a Telerik UI Checkbox instead -
@(Html.Kendo().CheckBoxFor(m => m)or - Remove the generated
data-val-requiredattribute when the checkbox is rendered -$('input[type="checkbox"]').removeAttr('data-val-required');(use a more specific selector if needed) or - Define a custom
Boolean.cshtmleditor and place it in~Views\Shared\EditorTemplates\folder where the visible<input type="checkbox" \>is wrapped in a container element and thedata-val-requiredattribute is missing.
@model bool
@{
var name = Html.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName("");
}
<div>
<input id="@name" name="@name" type="checkbox" value="true" data-bind="checked:@name">
</div>
<input name="@name" type="hidden" value="true" data-bind="value:@name">
<span class="field-validation-valid" data-valmsg-for="@name" data-valmsg-replace="true"></span>
Environment
- Kendo UI version: 202x.r.ddd
- jQuery version: x.y
- Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
Metadata
Metadata
Assignees
Labels
BugC: CheckboxFP: CompletedSync status with associated Feedback ItemSync status with associated Feedback ItemRegressionBroken functionality which was working previouslyBroken functionality which was working previouslyS: Wrappers (ASP.NET Core)S: Wrappers (ASP.NET MVC)SEV: High