public MvcForm BeginRouteForm(string routeName, FormMethod formMethod = FormMethod.Post, string formId = null, string errorTitle = null, IDictionary <string, object> htmlAttributes = null) { htmlAttributes = htmlAttributes ?? new Dictionary <string, object>(); htmlAttributes.Add("novalidate", "novalidate"); htmlAttributes.Merge("class", "js-validate js-validate-sync"); if (!string.IsNullOrWhiteSpace(formId)) { htmlAttributes.Add("data-form-id", formId); } if (!_modelState.IsValid) { // TODO: does this also need to return success status? htmlAttributes.Add("data-form-status", ToEncodedJson(FormValidationHelper.GetInvalidFormObject(_modelState, errorTitle))); } var formAction = UrlHelper.GenerateUrl(routeName, null, null, new RouteValueDictionary(), _html.RouteCollection, _html.ViewContext.RequestContext, false); return(FormHelperImpl(_html, formAction, formMethod, htmlAttributes)); }
private ModelStateErrors GetModelStateErrrors(string title) { return(FormValidationHelper.GetInvalidFormObject(_modelState, title)); }