mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Including Orchard.Fields
--HG-- branch : 1.x
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
@model Orchard.Fields.Fields.BooleanField
|
||||
@using Orchard.Utility.Extensions;
|
||||
@using Orchard.Fields.Settings;
|
||||
@{
|
||||
var settings = Model.PartFieldDefinition.Settings.GetModel<BooleanFieldSettings>();
|
||||
}
|
||||
<fieldset>
|
||||
<label for="@Html.FieldIdFor(m => m.Value)">@Model.DisplayName</label>
|
||||
@switch (settings.SelectionMode) {
|
||||
case SelectionMode.Checkbox:
|
||||
<input type="checkbox" id="@(Html.FieldIdFor(m => m.Value))" value="true" name="@Html.FieldNameFor(m => m.Value)" @if(Model.Value.HasValue && Model.Value.Value) { <text>checked="checked"</text> } /><input name="@Html.FieldNameFor(m => m.Value)" type="hidden" value="false" />
|
||||
<label class="forcheckbox" for="@(Html.FieldIdFor(m => m.Value))">@T(settings.OnLabel)</label>
|
||||
break;
|
||||
case SelectionMode.Radiobutton:
|
||||
if (settings.Optional) {
|
||||
<div>
|
||||
<input type="radio" name="@Html.FieldNameFor(m => m.Value)" id="radio-unknown" value="" @if(!Model.Value.HasValue) { <text>checked="checked"</text> } />
|
||||
<label for="radio-unknown" class="forcheckbox">@T(settings.NotSetLabel)</label>
|
||||
</div>
|
||||
}
|
||||
<div>
|
||||
<input type="radio" name="@Html.FieldNameFor(m => m.Value)" id="radio-true" value="true" @if (Model.Value.HasValue && Model.Value.Value) { <text>checked="checked"</text> } />
|
||||
<label for="radio-true" class="forcheckbox">@T(settings.OnLabel)</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="radio" name="@Html.FieldNameFor(m => m.Value)" id="radio-false" value="false" @if (Model.Value.HasValue && !Model.Value.Value) { <text>checked="checked"</text> } />
|
||||
<label for="radio-false" class="forcheckbox">@T(settings.OffLabel)</label>
|
||||
</div>
|
||||
break;
|
||||
case SelectionMode.Dropdown:
|
||||
<select id="@(Html.FieldIdFor(m => m.Value) + "-dropdown")" name="@Html.FieldNameFor(m => m.Value)">
|
||||
@if (settings.Optional) {
|
||||
@Html.SelectOption("", !Model.Value.HasValue, T(settings.NotSetLabel).ToString())
|
||||
}
|
||||
@Html.SelectOption("true", (Model.Value.HasValue && Model.Value.Value), T(settings.OnLabel).ToString())
|
||||
@Html.SelectOption("false", (Model.Value.HasValue && !Model.Value.Value), T(settings.OffLabel).ToString())
|
||||
</select>
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@Html.ValidationMessageFor(m => m.Value)
|
||||
<span class="hint">@settings.Hint</span>
|
||||
</fieldset>
|
Reference in New Issue
Block a user