mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-26 20:16:15 +08:00
committed by
Sébastien Ros
parent
2440e68c3f
commit
4b43b881f7
@@ -34,8 +34,14 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
Name: "Value",
|
||||
Title: "Value",
|
||||
Classes: new[] { "text", "medium", "tokenized" },
|
||||
Description: T("The value of this radio button.")));
|
||||
|
||||
Description: T("The value of this radio button.")),
|
||||
_DefaultValue:
|
||||
shape.Checkbox(
|
||||
Id: "DefaultValue",
|
||||
Name: "DefaultValue",
|
||||
Title: "Default Value",
|
||||
Value: "true",
|
||||
Description: T("Sets default value to unchecked or checked.")));
|
||||
return form;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
namespace Orchard.DynamicForms.Elements {
|
||||
using Orchard.Layouts.Elements;
|
||||
using Orchard.Layouts.Helpers;
|
||||
|
||||
namespace Orchard.DynamicForms.Elements {
|
||||
public class RadioButton : LabeledFormElement {
|
||||
public override string ToolboxIcon {
|
||||
get { return "\uf192"; }
|
||||
}
|
||||
public bool DefaultValue {
|
||||
get { return this.Retrieve(x => x.DefaultValue); }
|
||||
set { this.Store(x => x.DefaultValue, value); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,9 @@
|
||||
tagBuilder.Attributes["type"] = "radio";
|
||||
tagBuilder.Attributes["name"] = element.Name;
|
||||
tagBuilder.Attributes["value"] = element.Value;
|
||||
if (element.DefaultValue) {
|
||||
tagBuilder.Attributes["checked"] = "checked";
|
||||
}
|
||||
}
|
||||
@if (element.ShowLabel) {
|
||||
<label>
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
tagBuilder.Attributes["type"] = "radio";
|
||||
tagBuilder.Attributes["name"] = Model.ProcessedName;
|
||||
tagBuilder.Attributes["value"] = Model.ProcessedValue;
|
||||
if ((String.IsNullOrWhiteSpace(element.PostedValue) && element.DefaultValue) || Model.ProcessedValue == element.PostedValue) {
|
||||
tagBuilder.Attributes["checked"] = "checked";
|
||||
}
|
||||
}
|
||||
@if (element.ShowLabel) {
|
||||
<label>
|
||||
|
||||
Reference in New Issue
Block a user