public static MvcHtmlString AllValidationMessages(this MyFfHtmlHelper helper, string modelName) { if (HasErrors(helper, modelName)) { var message = string.Join(", ", helper.ViewData.ModelState[modelName].Errors.Select(e => e.ErrorMessage)); return(new MvcHtmlString(message)); } return(new MvcHtmlString("")); }
public static MvcHtmlString Render(this IEnumerable <PropertyVm> properties, MyFfHtmlHelper html) { var sb = new StringBuilder(); foreach (var propertyVm in properties) { sb.AppendLine(propertyVm.Render(html).ToString()); } return(new MvcHtmlString(sb.ToString())); }
public static string Render(this IEnumerable <PropertyVm> properties) { var helper = new MyFfHtmlHelper(); var sb = new StringBuilder(); foreach (var propertyVm in properties) { sb.AppendLine(propertyVm.Render(helper).ToString()).ToString(); } return(sb.ToString()); }
public static ObjectChoices[] Choices(this MyFfHtmlHelper html, PropertyVm model) { var choices = (from obj in model.Choices.Cast <object>().ToArray() let choiceType = obj == null ? model.Type : obj.GetType() let properties = FF.PropertiesFor(obj, choiceType) .Each(p => p.Name = model.Name + "." + p.Name) .Each(p => p.Readonly |= model.Readonly) .Each(p => p.Id = Guid.NewGuid().ToString()) select new ObjectChoices { obj = obj, choiceType = choiceType, properties = properties, name = (obj != null ? obj.DisplayName() : choiceType.DisplayName()) }).ToArray(); return(choices); }
public static PropertyVm CreatePropertyVm(this MyFfHtmlHelper helper, Type objectType, string name) { return(helper.CreatePropertyVm(objectType, name)); }
public static MvcHtmlString Render(this FormVm formVm, MyFfHtmlHelper html) { return(html.Partial("FormFactory/Form", formVm)); }
public static MvcHtmlString Render(this PropertyVm propertyVm, MyFfHtmlHelper html) { return(html.Partial("FormFactory/Form.Property", propertyVm)); }
public static MvcHtmlString BestProperty(this MyFfHtmlHelper html, PropertyVm vm) { string viewName = ViewFinderExtensions.BestPropertyName(html, vm); return(html.Partial(viewName, vm)); }
public static MvcHtmlString BestPartial(this MyFfHtmlHelper html, object model, Type type = null, string prefix = null) { var partialViewName = BestViewName(html, type ?? model.GetType(), prefix); return(html.Partial(partialViewName, model)); }
public static string BestViewName(this MyFfHtmlHelper html, Type type, string prefix = null) { return(FormFactory.ViewFinderExtensions.BestViewName(html, type, prefix)); }
public static MvcHtmlString UnobtrusiveValidation(this MyFfHtmlHelper helper, PropertyVm property) { var unobtrusiveValidation = ValidationHelper.UnobtrusiveValidation(helper, property); return(new MvcHtmlString(unobtrusiveValidation)); }
public static bool HasErrors(this MyFfHtmlHelper helper, string modelName) { return(helper.ViewData.ModelState.ContainsKey(modelName) && helper.ViewData.ModelState[modelName].Errors.Count() > 0); }