mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
46 lines
1.7 KiB
C#
46 lines
1.7 KiB
C#
using System.Collections.Generic;
|
|
using Orchard.DynamicForms.Elements;
|
|
using Orchard.Forms.Services;
|
|
using Orchard.Layouts.Framework.Display;
|
|
using Orchard.Layouts.Framework.Drivers;
|
|
using Orchard.Tokens;
|
|
using DescribeContext = Orchard.Forms.Services.DescribeContext;
|
|
|
|
namespace Orchard.DynamicForms.Drivers {
|
|
public class RadioButtonElementDriver : FormsElementDriver<RadioButton> {
|
|
private readonly ITokenizer _tokenizer;
|
|
|
|
public RadioButtonElementDriver(IFormManager formManager, ITokenizer tokenizer)
|
|
: base(formManager) {
|
|
_tokenizer = tokenizer;
|
|
}
|
|
|
|
protected override IEnumerable<string> FormNames {
|
|
get {
|
|
yield return "AutoLabel";
|
|
yield return "RadioButton";
|
|
}
|
|
}
|
|
|
|
protected override void DescribeForm(DescribeContext context) {
|
|
context.Form("RadioButton", factory => {
|
|
var shape = (dynamic)factory;
|
|
var form = shape.Fieldset(
|
|
Id: "RadioButton",
|
|
Description: T("The label for this radio button."),
|
|
_Value: shape.Textbox(
|
|
Id: "Value",
|
|
Name: "Value",
|
|
Title: "Value",
|
|
Classes: new[] { "text", "medium", "tokenized" },
|
|
Description: T("The value of this radio button.")));
|
|
|
|
return form;
|
|
});
|
|
}
|
|
|
|
protected override void OnDisplaying(RadioButton element, ElementDisplayingContext context) {
|
|
context.ElementShape.TokenizedValue = _tokenizer.Replace(element.Value, null);
|
|
}
|
|
}
|
|
} |