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);
                formTokenContext.CreatedContent = contentItem;
            }

            // Notifiy.
            if (!String.IsNullOrWhiteSpace(form.Notification))
            {
                _notifier.Success(T(_tokenizer.Replace(T(form.Notification).Text, tokenData)));
            }

            // Trigger workflow event.
            _workflowManager.TriggerEvent(DynamicFormSubmittedActivity.EventName, contentItem, () => tokenData);
        }
示例#2
0
        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);
        }
示例#3
0
 private string GetFieldValue(string fieldName, FormSubmissionTokenContext context)
 {
     return(context.PostedValues[fieldName]);
 }
示例#4
0
 private object GetFieldValidationStatus(string fieldName, FormSubmissionTokenContext context)
 {
     return(context.ModelState.IsValidField(fieldName));
 }
 private object GetCreatedContent(FormSubmissionTokenContext context)
 {
     return(context.CreatedContent);
 }