mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-01-19 17:51:45 +08:00
DynamicForms: Adding FormSubmission.FormName token
Contrib by Pablo Sanchez (https://github.com/psp589)
This commit is contained in:
@@ -10,7 +10,7 @@ namespace Orchard.DynamicForms.Tokens {
|
||||
.Token("Field:*", T("Field:<field name>"), T("The posted field value to access."), "Text")
|
||||
.Token("IsValid:*", T("IsValid:<field name>"), T("The posted field validation status."))
|
||||
.Token("CreatedContent", T("CreatedContent"), T("Id of the Content Item created by the form."))
|
||||
;
|
||||
.Token("FormName", T("FormName"), T("The name of the form posted."));
|
||||
}
|
||||
|
||||
public void Evaluate(EvaluateContext context) {
|
||||
@@ -19,7 +19,8 @@ namespace Orchard.DynamicForms.Tokens {
|
||||
.Chain(FilterChainParam, "Text", GetFieldValue)
|
||||
.Token(token => token.StartsWith("IsValid:", StringComparison.OrdinalIgnoreCase) ? token.Substring("IsValid:".Length) : null, GetFieldValidationStatus)
|
||||
.Token("CreatedContent", GetCreatedContent)
|
||||
.Chain("CreatedContent", "Content", GetCreatedContent);
|
||||
.Chain("CreatedContent", "Content", GetCreatedContent)
|
||||
.Token("FormName", GetFormName);
|
||||
}
|
||||
|
||||
private static Tuple<string, string> FilterChainParam(string token) {
|
||||
@@ -39,9 +40,12 @@ namespace Orchard.DynamicForms.Tokens {
|
||||
return context.ModelState.IsValidField(fieldName);
|
||||
}
|
||||
|
||||
private object GetCreatedContent(FormSubmissionTokenContext context)
|
||||
{
|
||||
private object GetCreatedContent(FormSubmissionTokenContext context) {
|
||||
return context.CreatedContent;
|
||||
}
|
||||
|
||||
private string GetFormName(FormSubmissionTokenContext context) {
|
||||
return context.Form.Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user