Switch to using string instead of bool for checkbox values
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
@model Boolean?
|
||||
|
||||
@{
|
||||
Layout = "_FieldLayout.cshtml";
|
||||
|
||||
var htmlAttributes = new RouteValueDictionary();
|
||||
if (ViewBag.@class != null)
|
||||
{
|
||||
htmlAttributes.Add("class", ViewBag.@class);
|
||||
}
|
||||
}
|
||||
|
||||
@if (Model.HasValue && Model.Value)
|
||||
{
|
||||
<input id="@ViewData.TemplateInfo.GetFullHtmlFieldId("")" name="@ViewData.TemplateInfo.GetFullHtmlFieldId("")"
|
||||
type="checkbox" checked="checked" />
|
||||
}
|
||||
else
|
||||
{
|
||||
<input id="@ViewData.TemplateInfo.GetFullHtmlFieldId("")" name="@ViewData.TemplateInfo.GetFullHtmlFieldId("")"
|
||||
type="checkbox" />
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
@model string
|
||||
@{
|
||||
Layout = "_FieldLayout.cshtml";
|
||||
|
||||
var htmlAttributes = new RouteValueDictionary();
|
||||
if (ViewBag.@class != null)
|
||||
{
|
||||
htmlAttributes.Add("class", ViewBag.@class);
|
||||
}
|
||||
|
||||
var isChecked = !string.IsNullOrEmpty(Model);
|
||||
var id = ViewData.TemplateInfo.GetFullHtmlFieldId("");
|
||||
}
|
||||
|
||||
<input id="@id" name="@id" type="checkbox" @if(isChecked) {<text>checked="checked"</text>} />
|
||||
@@ -1,14 +1,14 @@
|
||||
@if (TempData.ContainsKey("StatusMessage"))
|
||||
{
|
||||
<p class="alert @Html.Raw(TempData["StatusMessage-Type"]) alert-dismissible fade show">
|
||||
<div class="alert @Html.Raw(TempData["StatusMessage-Type"]) alert-dismissible fade show">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
@Html.Raw(TempData["StatusMessage"])
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
else if (ViewBag.StatusMessage != null)
|
||||
{
|
||||
<p class="alert alert-dismissible fade show">
|
||||
<div class="alert alert-dismissible fade show">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
@ViewBag.StatusMessage
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
Reference in New Issue
Block a user