public override void Validating(FormValidatingEventContext context) { var form = context.Form; var values = context.Values; var formValuesDictionary = values.ToTokenDictionary(); var formTokenContext = new FormSubmissionTokenContext { Form = form, ModelState = context.ModelState, PostedValues = values }; var tokensData = new Dictionary<string, object>(formValuesDictionary) { {"Updater", context.Updater}, {"FormSubmission", formTokenContext}, }; _workflowManager.TriggerEvent(name: DynamicFormValidatingActivity.EventName, target: null, tokensContext: () => tokensData); }
public override void Validated(FormValidatedEventContext context) { if (!context.ModelState.IsValid) return; var form = context.Form; var formName = form.Name; var values = context.Values; var formService = context.FormService; var formValuesDictionary = values.ToTokenDictionary(); var formTokenContext = new FormSubmissionTokenContext { Form = form, ModelState = context.ModelState, PostedValues = values }; var tokenData = new Dictionary<string, object>(formValuesDictionary) { {"Updater", context.Updater}, {"FormSubmission", formTokenContext}, {"Content", context.Content } }; // Store the submission. if (form.StoreSubmission == true) { formService.CreateSubmission(formName, values); } // Create content item. var contentItem = default(ContentItem); if (form.CreateContent == true && !String.IsNullOrWhiteSpace(form.FormBindingContentType)) { contentItem = formService.CreateContentItem(form, context.ValueProvider); } // Notifiy. if (!String.IsNullOrWhiteSpace(form.Notification)) _notifier.Information(T(_tokenizer.Replace(T(form.Notification).Text, tokenData))); // Trigger workflow event. _workflowManager.TriggerEvent(DynamicFormSubmittedActivity.EventName, contentItem, () => tokenData); }
private object GetFieldValidationStatus(string fieldName, FormSubmissionTokenContext context) { return context.ModelState.IsValidField(fieldName); }
private string GetFieldValue(string fieldName, FormSubmissionTokenContext context) { return context.PostedValues[fieldName]; }