public override void Validated(FormValidatedEventContext context)
        {
            if (!context.ModelState.IsValid)
            {
                //Clean up on validation fail
                foreach (var element in context.Form.Elements)
                {
                    if (element is FileField)
                    {
                        var fileFieldElement = (FileField)element;

                        var path = context.Values[fileFieldElement.Name];

                        if (!string.IsNullOrWhiteSpace(path) && File.Exists(path))
                            File.Delete(path);
                    }
                }
            }
        }
        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);
        }
 public virtual void Validated(FormValidatedEventContext context) {}