private void FormModelOnBeforeAddToIndex(FormModel sender, FormEditorCancelEventArgs formEditorCancelEventArgs) { if(sender.AllValueFields().Any(f => f.HasSubmittedValue && f.SubmittedValue.Equals("bad", StringComparison.InvariantCultureIgnoreCase))) { formEditorCancelEventArgs.Cancel = true; formEditorCancelEventArgs.ErrorMessage = "Bad values are not accepted."; } }
public static string Render(string viewName, FormModel model, IPublishedContent currentContent) { var viewPath = Path.Combine(EmailViewPath, viewName); var viewFile = new FileInfo(HostingEnvironment.MapPath(viewPath)); if (viewFile.Exists == false) { return(null); } var writer = new StringWriter(); var context = new HttpContextWrapper(HttpContext.Current); var routeData = new RouteData(); var controllerContext = new ControllerContext(new RequestContext(context, routeData), new FakeController()); var razor = new RazorView(controllerContext, viewPath, null, false, null); var viewData = new ViewDataDictionary(model); // pass the current content to the email template, because Umbraco.AssignedContentItem doesn't work out of Umbraco context viewData["currentContent"] = currentContent; razor.Render(new ViewContext(controllerContext, razor, viewData, new TempDataDictionary(), writer), writer); return(writer.ToString()); }
public static string SerializeFormModel(FormModel formModel) { return(formModel == null ? null : FormatJson(JsonConvert.SerializeObject(formModel, SerializerSettings))); }
private void FormModelOnAfterAddToIndex(FormModel sender, FormEditorEventArgs formEditorEventArgs) { Log.Info("Something was added to the index."); }