mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +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) {
|
protected override void OnDisplaying(EmailField element, ElementDisplayingContext context) {
|
||||||
context.ElementShape.ProcessedName = _tokenizer.Replace(element.Name, context.GetTokenData());
|
var tokenData = context.GetTokenData();
|
||||||
context.ElementShape.ProcessedLabel = _tokenizer.Replace(element.Label, context.GetTokenData(), new ReplaceOptions { Encoding = ReplaceOptions.NoEncode });
|
context.ElementShape.ProcessedName = _tokenizer.Replace(element.Name, tokenData);
|
||||||
context.ElementShape.ProcessedValue = element.RuntimeValue;
|
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",
|
Id: "InputType",
|
||||||
Name: "InputType",
|
Name: "InputType",
|
||||||
Title: "Input Type",
|
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("Select List").Text, Value = "SelectList" });
|
||||||
form._InputType.Items.Add(new SelectListItem { Text = T("Multi Select List").Text, Value = "MultiSelectList" });
|
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 displayType = context.DisplayType;
|
||||||
var tokenData = context.GetTokenData();
|
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.ProcessedName = _tokenizer.Replace(element.Name, tokenData);
|
||||||
context.ElementShape.ProcessedLabel = _tokenizer.Replace(element.Label, tokenData, new ReplaceOptions { Encoding = ReplaceOptions.NoEncode });
|
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();
|
context.ElementShape.ProcessedOptions = _tokenizer.Replace(element.Options, tokenData, new ReplaceOptions { Encoding = ReplaceOptions.NoEncode }).ToArray();
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace Orchard.DynamicForms.Drivers {
|
|||||||
Id: "Value",
|
Id: "Value",
|
||||||
Name: "Value",
|
Name: "Value",
|
||||||
Title: "Value",
|
Title: "Value",
|
||||||
Classes: new[] { "text", "medium" },
|
Classes: new[] { "text", "medium", "tokenized" },
|
||||||
Description: T("The value of this hidden field.")));
|
Description: T("The value of this hidden field.")));
|
||||||
|
|
||||||
return form;
|
return form;
|
||||||
@@ -35,8 +35,12 @@ namespace Orchard.DynamicForms.Drivers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnDisplaying(HiddenField element, ElementDisplayingContext context) {
|
protected override void OnDisplaying(HiddenField element, ElementDisplayingContext context) {
|
||||||
context.ElementShape.ProcessedName = _tokenizer.Replace(element.Name, context.GetTokenData());
|
var tokenData = context.GetTokenData();
|
||||||
context.ElementShape.ProcessedValue = element.RuntimeValue ?? string.Empty;
|
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}",
|
Value: "{Content.Id}",
|
||||||
Description: T("Specify the expression to get the value of each option."),
|
Description: T("Specify the expression to get the value of each option."),
|
||||||
Classes: new[]{"text", "large", "tokenized"}),
|
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(
|
_InputType: shape.SelectList(
|
||||||
Id: "InputType",
|
Id: "InputType",
|
||||||
Name: "InputType",
|
Name: "InputType",
|
||||||
@@ -122,6 +128,13 @@ namespace Orchard.DynamicForms.Drivers {
|
|||||||
var displayType = context.DisplayType;
|
var displayType = context.DisplayType;
|
||||||
var tokenData = context.GetTokenData();
|
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.ProcessedName = _tokenizer.Replace(element.Name, tokenData);
|
||||||
context.ElementShape.ProcessedLabel = _tokenizer.Replace(element.Label, tokenData);
|
context.ElementShape.ProcessedLabel = _tokenizer.Replace(element.Label, tokenData);
|
||||||
context.ElementShape.Options = GetOptions(element, context.DisplayType, queryId, tokenData).ToArray();
|
context.ElementShape.Options = GetOptions(element, context.DisplayType, queryId, tokenData).ToArray();
|
||||||
|
|||||||
@@ -67,6 +67,12 @@ namespace Orchard.DynamicForms.Drivers {
|
|||||||
Value: "{Content.Id}",
|
Value: "{Content.Id}",
|
||||||
Description: T("Specify the expression to get the value of each option."),
|
Description: T("Specify the expression to get the value of each option."),
|
||||||
Classes: new[] { "text", "large", "tokenized" }),
|
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(
|
_InputType: shape.SelectList(
|
||||||
Id: "InputType",
|
Id: "InputType",
|
||||||
Name: "InputType",
|
Name: "InputType",
|
||||||
@@ -126,6 +132,13 @@ namespace Orchard.DynamicForms.Drivers {
|
|||||||
var displayType = context.DisplayType;
|
var displayType = context.DisplayType;
|
||||||
var tokenData = context.GetTokenData();
|
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.ProcessedName = _tokenizer.Replace(element.Name, tokenData);
|
||||||
context.ElementShape.ProcessedLabel = _tokenizer.Replace(element.Label, tokenData, new ReplaceOptions { Encoding = ReplaceOptions.NoEncode });
|
context.ElementShape.ProcessedLabel = _tokenizer.Replace(element.Label, tokenData, new ReplaceOptions { Encoding = ReplaceOptions.NoEncode });
|
||||||
context.ElementShape.TermOptions = GetTermOptions(element, context.DisplayType, taxonomyId, tokenData).ToArray();
|
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) {
|
protected override void OnDisplaying(TextArea element, ElementDisplayingContext context) {
|
||||||
context.ElementShape.ProcessedName = _tokenizer.Replace(element.Name, context.GetTokenData());
|
var tokenData = context.GetTokenData();
|
||||||
context.ElementShape.ProcessedLabel = _tokenizer.Replace(element.Label, context.GetTokenData(), new ReplaceOptions { Encoding = ReplaceOptions.NoEncode });
|
context.ElementShape.ProcessedName = _tokenizer.Replace(element.Name, tokenData);
|
||||||
context.ElementShape.ProcessedValue = element.RuntimeValue;
|
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) {
|
protected override void OnDisplaying(TextField element, ElementDisplayingContext context) {
|
||||||
context.ElementShape.ProcessedName = _tokenizer.Replace(element.Name, context.GetTokenData());
|
var tokenData = context.GetTokenData();
|
||||||
context.ElementShape.ProcessedLabel = _tokenizer.Replace(element.Label, context.GetTokenData(), new ReplaceOptions {Encoding = ReplaceOptions.NoEncode});
|
context.ElementShape.ProcessedName = _tokenizer.Replace(element.Name, tokenData);
|
||||||
context.ElementShape.ProcessedValue = element.RuntimeValue;
|
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) {
|
protected override void OnDisplaying(UrlField element, ElementDisplayingContext context) {
|
||||||
context.ElementShape.ProcessedName = _tokenizer.Replace(element.Name, context.GetTokenData());
|
var tokenData = context.GetTokenData();
|
||||||
context.ElementShape.ProcessedLabel = _tokenizer.Replace(element.Label, context.GetTokenData(), new ReplaceOptions { Encoding = ReplaceOptions.NoEncode });
|
context.ElementShape.ProcessedName = _tokenizer.Replace(element.Name, tokenData);
|
||||||
context.ElementShape.ProcessedValue = element.RuntimeValue;
|
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; }
|
get { return _options.Value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string DefaultValue {
|
||||||
|
get { return this.Retrieve(x => x.DefaultValue); }
|
||||||
|
}
|
||||||
|
|
||||||
public IEnumerable<string> RuntimeValues {
|
public IEnumerable<string> RuntimeValues {
|
||||||
get { return _runtimeValues.Value; }
|
get { return _runtimeValues.Value; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,10 @@ namespace Orchard.DynamicForms.Elements {
|
|||||||
get { return this.Retrieve(x => x.ValueExpression, () => "{Content.Id}"); }
|
get { return this.Retrieve(x => x.ValueExpression, () => "{Content.Id}"); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string DefaultValue {
|
||||||
|
get { return this.Retrieve(x => x.DefaultValue); }
|
||||||
|
}
|
||||||
|
|
||||||
public EnumerationValidationSettings ValidationSettings {
|
public EnumerationValidationSettings ValidationSettings {
|
||||||
get { return Data.GetModel<EnumerationValidationSettings>(""); }
|
get { return Data.GetModel<EnumerationValidationSettings>(""); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,10 @@ namespace Orchard.DynamicForms.Elements {
|
|||||||
set { this.Store(x => x.ValueExpression, value); }
|
set { this.Store(x => x.ValueExpression, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string DefaultValue {
|
||||||
|
get { return this.Retrieve(x => x.DefaultValue); }
|
||||||
|
}
|
||||||
|
|
||||||
public EnumerationValidationSettings ValidationSettings {
|
public EnumerationValidationSettings ValidationSettings {
|
||||||
get { return Data.GetModel<EnumerationValidationSettings>(""); }
|
get { return Data.GetModel<EnumerationValidationSettings>(""); }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user