public string GetDefault(IHtmlHelper helper, Webpage webpage, FormSubmittedStatus submittedStatus) { if (webpage == null) { return(string.Empty); } var formProperties = webpage.FormProperties.OrderBy(x => x.DisplayOrder); if (!formProperties.Any()) { return(string.Empty); } var form = GetForm(webpage); foreach (var property in formProperties) { string elementHtml = string.Empty; IFormElementRenderer renderer = _elementRendererManager.GetElementRenderer(property); elementHtml += _labelRenderer.AppendLabel(property); var existingValue = submittedStatus.Data[property.Name]; elementHtml += renderer.AppendElement(property, existingValue, _siteSettings.FormRendererType) .ToString(renderer.IsSelfClosing ? TagRenderMode.SelfClosing : TagRenderMode.Normal); elementHtml += _validationMessaageRenderer.AppendRequiredMessage(property); var elementContainer = _elementRendererManager.GetElementContainer(_siteSettings.FormRendererType, property); if (elementContainer != null) { elementContainer.InnerHtml += elementHtml; form.InnerHtml += elementContainer; } else { form.InnerHtml += elementHtml; } } form.InnerHtml += helper.RenderRecaptcha().ToString(); var div = new TagBuilder("div"); div.InnerHtml += GetSubmitButton(webpage).ToString(TagRenderMode.SelfClosing); form.InnerHtml += div; if (submittedStatus.Submitted) { form.InnerHtml += new TagBuilder("br"); form.InnerHtml += _submittedMessageRenderer.AppendSubmittedMessage(webpage, submittedStatus); } if (_siteSettings.HasHoneyPot) { form.InnerHtml += _siteSettings.GetHoneypot(); } return(form.ToString()); }
private MatchEvaluator AddValidation(IList <FormProperty> formProperties) { return(match => { var formProperty = formProperties.FirstOrDefault( property => property.Name.Equals(match.Groups[1].Value, StringComparison.OrdinalIgnoreCase)); return formProperty == null ? string.Empty : _validationMessaageRenderer.AppendRequiredMessage(formProperty).ToString(); }); }