mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-27 04:19:04 +08:00
Allow the initial value of some fields to be tokenized (#6613)
Fixes #6613 Fixes #6237
This commit is contained in:
@@ -77,9 +77,13 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
}
|
||||
|
||||
protected override void OnDisplaying(EmailField element, ElementDisplayingContext context) {
|
||||
context.ElementShape.ProcessedName = _tokenizer.Replace(element.Name, context.GetTokenData());
|
||||
context.ElementShape.ProcessedLabel = _tokenizer.Replace(element.Label, context.GetTokenData(), new ReplaceOptions { Encoding = ReplaceOptions.NoEncode });
|
||||
context.ElementShape.ProcessedValue = element.RuntimeValue;
|
||||
var tokenData = context.GetTokenData();
|
||||
context.ElementShape.ProcessedName = _tokenizer.Replace(element.Name, tokenData);
|
||||
context.ElementShape.ProcessedLabel = _tokenizer.Replace(element.Label, tokenData, new ReplaceOptions { Encoding = ReplaceOptions.NoEncode });
|
||||
|
||||
// Allow the initial value to be tokenized.
|
||||
// If a value was posted, use that value instead (without tokenizing it).
|
||||
context.ElementShape.ProcessedValue = element.PostedValue != null ? element.PostedValue : _tokenizer.Replace(element.RuntimeValue, tokenData, new ReplaceOptions { Encoding = ReplaceOptions.NoEncode });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,13 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
Id: "InputType",
|
||||
Name: "InputType",
|
||||
Title: "Input Type",
|
||||
Description: T("The control to render when presenting the list of options.")));
|
||||
Description: T("The control to render when presenting the list of options.")),
|
||||
_DefaultValue: shape.Textbox(
|
||||
Id: "DefaultValue",
|
||||
Name: "DefaultValue",
|
||||
Title: "Default Value",
|
||||
Classes: new[] { "text", "large", "tokenized" },
|
||||
Description: T("The default value of this enumeration field.")));
|
||||
|
||||
form._InputType.Items.Add(new SelectListItem { Text = T("Select List").Text, Value = "SelectList" });
|
||||
form._InputType.Items.Add(new SelectListItem { Text = T("Multi Select List").Text, Value = "MultiSelectList" });
|
||||
@@ -83,6 +89,13 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
var displayType = context.DisplayType;
|
||||
var tokenData = context.GetTokenData();
|
||||
|
||||
// Allow the initially selected value to be tokenized.
|
||||
// If a value was posted, use that value instead (without tokenizing it).
|
||||
if (element.PostedValue == null) {
|
||||
var defaultValue = _tokenizer.Replace(element.DefaultValue, tokenData, new ReplaceOptions { Encoding = ReplaceOptions.NoEncode });
|
||||
element.RuntimeValue = defaultValue;
|
||||
}
|
||||
|
||||
context.ElementShape.ProcessedName = _tokenizer.Replace(element.Name, tokenData);
|
||||
context.ElementShape.ProcessedLabel = _tokenizer.Replace(element.Label, tokenData, new ReplaceOptions { Encoding = ReplaceOptions.NoEncode });
|
||||
context.ElementShape.ProcessedOptions = _tokenizer.Replace(element.Options, tokenData, new ReplaceOptions { Encoding = ReplaceOptions.NoEncode }).ToArray();
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
Id: "Value",
|
||||
Name: "Value",
|
||||
Title: "Value",
|
||||
Classes: new[] { "text", "medium" },
|
||||
Classes: new[] { "text", "medium", "tokenized" },
|
||||
Description: T("The value of this hidden field.")));
|
||||
|
||||
return form;
|
||||
@@ -35,8 +35,12 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
}
|
||||
|
||||
protected override void OnDisplaying(HiddenField element, ElementDisplayingContext context) {
|
||||
context.ElementShape.ProcessedName = _tokenizer.Replace(element.Name, context.GetTokenData());
|
||||
context.ElementShape.ProcessedValue = element.RuntimeValue ?? string.Empty;
|
||||
var tokenData = context.GetTokenData();
|
||||
context.ElementShape.ProcessedName = _tokenizer.Replace(element.Name, tokenData);
|
||||
|
||||
// Allow the initial value to be tokenized.
|
||||
// If a value was posted, use that value instead (without tokenizing it).
|
||||
context.ElementShape.ProcessedValue = element.PostedValue != null ? element.PostedValue : _tokenizer.Replace(element.RuntimeValue, tokenData, new ReplaceOptions { Encoding = ReplaceOptions.NoEncode });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,6 +68,12 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
Value: "{Content.Id}",
|
||||
Description: T("Specify the expression to get the value of each option."),
|
||||
Classes: new[]{"text", "large", "tokenized"}),
|
||||
_DefaultValue: shape.Textbox(
|
||||
Id: "DefaultValue",
|
||||
Name: "DefaultValue",
|
||||
Title: "Default Value",
|
||||
Classes: new[] { "text", "large", "tokenized" },
|
||||
Description: T("The default value of this query field.")),
|
||||
_InputType: shape.SelectList(
|
||||
Id: "InputType",
|
||||
Name: "InputType",
|
||||
@@ -122,6 +128,13 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
var displayType = context.DisplayType;
|
||||
var tokenData = context.GetTokenData();
|
||||
|
||||
// Allow the initially selected value to be tokenized.
|
||||
// If a value was posted, use that value instead (without tokenizing it).
|
||||
if (element.PostedValue == null) {
|
||||
var defaultValue = _tokenizer.Replace(element.DefaultValue, tokenData, new ReplaceOptions { Encoding = ReplaceOptions.NoEncode });
|
||||
element.RuntimeValue = defaultValue;
|
||||
}
|
||||
|
||||
context.ElementShape.ProcessedName = _tokenizer.Replace(element.Name, tokenData);
|
||||
context.ElementShape.ProcessedLabel = _tokenizer.Replace(element.Label, tokenData);
|
||||
context.ElementShape.Options = GetOptions(element, context.DisplayType, queryId, tokenData).ToArray();
|
||||
|
||||
@@ -67,6 +67,12 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
Value: "{Content.Id}",
|
||||
Description: T("Specify the expression to get the value of each option."),
|
||||
Classes: new[] { "text", "large", "tokenized" }),
|
||||
_DefaultValue: shape.Textbox(
|
||||
Id: "DefaultValue",
|
||||
Name: "DefaultValue",
|
||||
Title: "Default Value",
|
||||
Classes: new[] { "text", "large", "tokenized" },
|
||||
Description: T("The default value of this query field.")),
|
||||
_InputType: shape.SelectList(
|
||||
Id: "InputType",
|
||||
Name: "InputType",
|
||||
@@ -126,6 +132,13 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
var displayType = context.DisplayType;
|
||||
var tokenData = context.GetTokenData();
|
||||
|
||||
// Allow the initially selected value to be tokenized.
|
||||
// If a value was posted, use that value instead (without tokenizing it).
|
||||
if (element.PostedValue == null) {
|
||||
var defaultValue = _tokenizer.Replace(element.DefaultValue, tokenData, new ReplaceOptions { Encoding = ReplaceOptions.NoEncode });
|
||||
element.RuntimeValue = defaultValue;
|
||||
}
|
||||
|
||||
context.ElementShape.ProcessedName = _tokenizer.Replace(element.Name, tokenData);
|
||||
context.ElementShape.ProcessedLabel = _tokenizer.Replace(element.Label, tokenData, new ReplaceOptions { Encoding = ReplaceOptions.NoEncode });
|
||||
context.ElementShape.TermOptions = GetTermOptions(element, context.DisplayType, taxonomyId, tokenData).ToArray();
|
||||
|
||||
@@ -88,9 +88,13 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
}
|
||||
|
||||
protected override void OnDisplaying(TextArea element, ElementDisplayingContext context) {
|
||||
context.ElementShape.ProcessedName = _tokenizer.Replace(element.Name, context.GetTokenData());
|
||||
context.ElementShape.ProcessedLabel = _tokenizer.Replace(element.Label, context.GetTokenData(), new ReplaceOptions { Encoding = ReplaceOptions.NoEncode });
|
||||
context.ElementShape.ProcessedValue = element.RuntimeValue;
|
||||
var tokenData = context.GetTokenData();
|
||||
context.ElementShape.ProcessedName = _tokenizer.Replace(element.Name, tokenData);
|
||||
context.ElementShape.ProcessedLabel = _tokenizer.Replace(element.Label, tokenData, new ReplaceOptions { Encoding = ReplaceOptions.NoEncode });
|
||||
|
||||
// Allow the initial value to be tokenized.
|
||||
// If a value was posted, use that value instead (without tokenizing it).
|
||||
context.ElementShape.ProcessedValue = element.PostedValue != null ? element.PostedValue : _tokenizer.Replace(element.RuntimeValue, tokenData, new ReplaceOptions { Encoding = ReplaceOptions.NoEncode });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -83,9 +83,13 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
}
|
||||
|
||||
protected override void OnDisplaying(TextField element, ElementDisplayingContext context) {
|
||||
context.ElementShape.ProcessedName = _tokenizer.Replace(element.Name, context.GetTokenData());
|
||||
context.ElementShape.ProcessedLabel = _tokenizer.Replace(element.Label, context.GetTokenData(), new ReplaceOptions {Encoding = ReplaceOptions.NoEncode});
|
||||
context.ElementShape.ProcessedValue = element.RuntimeValue;
|
||||
var tokenData = context.GetTokenData();
|
||||
context.ElementShape.ProcessedName = _tokenizer.Replace(element.Name, tokenData);
|
||||
context.ElementShape.ProcessedLabel = _tokenizer.Replace(element.Label, tokenData, new ReplaceOptions { Encoding = ReplaceOptions.NoEncode });
|
||||
|
||||
// Allow the initial value to be tokenized.
|
||||
// If a value was posted, use that value instead (without tokenizing it).
|
||||
context.ElementShape.ProcessedValue = element.PostedValue != null ? element.PostedValue : _tokenizer.Replace(element.RuntimeValue, tokenData, new ReplaceOptions { Encoding = ReplaceOptions.NoEncode });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -71,9 +71,13 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
}
|
||||
|
||||
protected override void OnDisplaying(UrlField element, ElementDisplayingContext context) {
|
||||
context.ElementShape.ProcessedName = _tokenizer.Replace(element.Name, context.GetTokenData());
|
||||
context.ElementShape.ProcessedLabel = _tokenizer.Replace(element.Label, context.GetTokenData(), new ReplaceOptions { Encoding = ReplaceOptions.NoEncode });
|
||||
context.ElementShape.ProcessedValue = element.RuntimeValue;
|
||||
var tokenData = context.GetTokenData();
|
||||
context.ElementShape.ProcessedName = _tokenizer.Replace(element.Name, tokenData);
|
||||
context.ElementShape.ProcessedLabel = _tokenizer.Replace(element.Label, tokenData, new ReplaceOptions { Encoding = ReplaceOptions.NoEncode });
|
||||
|
||||
// Allow the initial value to be tokenized.
|
||||
// If a value was posted, use that value instead (without tokenizing it).
|
||||
context.ElementShape.ProcessedValue = element.PostedValue != null ? element.PostedValue : _tokenizer.Replace(element.RuntimeValue, tokenData, new ReplaceOptions { Encoding = ReplaceOptions.NoEncode });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,10 @@ namespace Orchard.DynamicForms.Elements {
|
||||
get { return _options.Value; }
|
||||
}
|
||||
|
||||
public string DefaultValue {
|
||||
get { return this.Retrieve(x => x.DefaultValue); }
|
||||
}
|
||||
|
||||
public IEnumerable<string> RuntimeValues {
|
||||
get { return _runtimeValues.Value; }
|
||||
}
|
||||
|
||||
@@ -27,6 +27,10 @@ namespace Orchard.DynamicForms.Elements {
|
||||
get { return this.Retrieve(x => x.ValueExpression, () => "{Content.Id}"); }
|
||||
}
|
||||
|
||||
public string DefaultValue {
|
||||
get { return this.Retrieve(x => x.DefaultValue); }
|
||||
}
|
||||
|
||||
public EnumerationValidationSettings ValidationSettings {
|
||||
get { return Data.GetModel<EnumerationValidationSettings>(""); }
|
||||
}
|
||||
|
||||
@@ -34,6 +34,10 @@ namespace Orchard.DynamicForms.Elements {
|
||||
set { this.Store(x => x.ValueExpression, value); }
|
||||
}
|
||||
|
||||
public string DefaultValue {
|
||||
get { return this.Retrieve(x => x.DefaultValue); }
|
||||
}
|
||||
|
||||
public EnumerationValidationSettings ValidationSettings {
|
||||
get { return Data.GetModel<EnumerationValidationSettings>(""); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user