public override string Render(IControl control, object htmlAttributes) { var id = control.Name; var displayName = !string.IsNullOrEmpty(control.Label) ? control.Label : control.Name; var div = new MultiLevelTag("div"); div.AddCssClass("form-inner"); var input = new MultiLevelTag("input"); input.Attributes.Add("id", id); input.Attributes.Add("name", id); input.Attributes.Add("type", "email"); input.Attributes.Add("value", control.DefaultValue); CustomHtml(input, htmlAttributes); IsRequired(control, input, displayName); foreach (var validation in control.Validation) { input.Attributes.Add($"data-rule-{validation.ValidationRule}", validation.ValidationValue); input.Attributes.Add($"data-msg-{validation.ValidationRule}", validation.ValidationErrorMessage); } div.Add(input); ExplanationText(control, div); ToolTip(control, input); return(div.ToString()); }
public override string Render(IControl control, object htmlAttributes) { var id = control.Name; var displayName = !string.IsNullOrEmpty(control.Label) ? control.Label : control.Name; var div = new MultiLevelTag("div"); div.AddCssClass("form-inner"); var input = new MultiLevelTag("input"); input.Attributes.Add("id", id); input.Attributes.Add("name", id); input.Attributes.Add("type", "text"); input.Attributes.Add("readonly", null); CustomHtml(input, htmlAttributes); if (!String.IsNullOrEmpty(control.DefaultValue)) { input.Attributes.Add("value", control.DefaultValue.ToDateTime(DateTime.Now, "en-GB").ToString("dd/MM/yyyy")); } input.AddCssClass("datepicker"); IsRequired(control, input, displayName); div.Add(input); ExplanationText(control, div); ToolTip(control, input); return(div.ToString()); }
public override string Render(IControl control, object htmlAttributes) { var id = control.Name; var displayName = !string.IsNullOrEmpty(control.Label) ? control.Label : control.Name; var div = new MultiLevelTag("div"); div.AddCssClass("form-inner"); var rte = new MultiLevelTag("textarea"); rte.Attributes.Add("id", id); rte.Attributes.Add("name", id); rte.AddCssClass("rich-text-editor"); CustomHtml(rte, htmlAttributes); IsRequired(control, rte, displayName); div.Add(rte); ExplanationText(control, div); ToolTip(control, rte); return(div.ToString()); }
public override string Render(IControl control, object htmlAttributes) { var id = control.Name; var displayName = !string.IsNullOrEmpty(control.Label) ? control.Label : control.Name; var div = new MultiLevelTag("div"); div.AddCssClass("form-inner"); var items = control.DefaultValues; var count = 1; foreach (var innerItem in items) { var input = new MultiLevelTag("input"); input.Attributes.Add("id", $"{id}_{count}"); input.Attributes.Add("name", $"{id}"); input.Attributes.Add("value", $"{innerItem.Key}"); input.Attributes.Add("type", "checkbox"); if (innerItem.Value) { input.Attributes.Add("checked", null); } if (control.IsRequired) { input.Attributes.Add("required", null); input.Attributes.Add("minlength", "1"); } CustomHtml(input, htmlAttributes); var label = new MultiLevelTag("label"); label.Attributes.Add("for", $"{id}_{count}"); label.SetInnerText(innerItem.Key); var checkboxDiv = new MultiLevelTag("div"); checkboxDiv.AddCssClass("form-checkbox"); checkboxDiv.Add(input); checkboxDiv.Add(label); div.Add(checkboxDiv); count++; } IsRequired(control, div, displayName); ExplanationText(control, div); ToolTip(control, div); return(div.ToString()); }
public override string Render(IControl control, object htmlAttributes) { var id = control.Name; var displayName = !string.IsNullOrEmpty(control.Label) ? control.Label : control.Name; var div = new MultiLevelTag("div"); div.AddCssClass("form-inner"); var input = new MultiLevelTag("input"); input.Attributes.Add("id", $"{id}"); input.Attributes.Add("name", id); input.Attributes.Add("type", "checkbox"); input.Attributes.Add("value", $"{id}"); CustomHtml(input, htmlAttributes); if (control.DefaultValue == "True") { input.Attributes.Add("checked", ""); } IsRequired(control, input, displayName); foreach (var validation in control.Validation) { input.Attributes.Add($"data-rule-{validation.ValidationRule}", validation.ValidationValue); input.Attributes.Add($"data-msg-{validation.ValidationRule}", validation.ValidationErrorMessage); } var required = control.IsRequired ? " form-label--required" : string.Empty; var label = new MultiLevelTag("label"); label.Attributes.Add("for", $"{id}"); label.SetInnerText(displayName); label.Attributes.Add("class", $"form-label{required}"); div.Add(input); div.Add(label); ExplanationText(control, div); ToolTip(control, input); return(div.ToString()); }
public string Render(IControl control, object htmlAttributes) { if (String.IsNullOrWhiteSpace(control.Label)) { return(""); } var id = control.Name; var required = control.IsRequired ? " form-label--required" : string.Empty; var tb = new MultiLevelTag("label") { InnerHtml = $"{control.Label}" }; tb.Attributes.Add("for", id); tb.Attributes.Add("class", $"form-label{required}"); return(tb.ToString()); }
public override string Render(IControl control, object htmlAttributes) { var id = control.Name; var displayName = !string.IsNullOrEmpty(control.Label) ? control.Label : control.Name; var div = new MultiLevelTag("div"); div.AddCssClass("form-inner"); var ddl = new MultiLevelTag("select"); ddl.Attributes.Add("id", id); ddl.Attributes.Add("name", id); CustomHtml(ddl, htmlAttributes); var items = control.DefaultValues; foreach (var innerItem in items) { var option = new MultiLevelTag("option") { InnerHtml = innerItem.Key }; if (innerItem.Value) { option.Attributes.Add("selected", null); } ddl.Add(option); } IsRequired(control, ddl, displayName); div.Add(ddl); ExplanationText(control, div); ToolTip(control, ddl); return(div.ToString()); }
public override string Render(IControl control, object htmlAttributes) { var id = control.Name; var displayName = !string.IsNullOrEmpty(control.Label) ? control.Label : control.Name; var div = new MultiLevelTag("div"); div.AddCssClass("form-inner"); var textarea = new MultiLevelTag("textarea"); textarea.Attributes.Add("id", id); textarea.Attributes.Add("name", id); textarea.Attributes.Add("value", control.DefaultValue); CustomHtml(textarea, htmlAttributes); IsRequired(control, textarea, displayName); foreach (var validation in control.Validation) { textarea.Attributes.Add($"data-rule-{validation.ValidationRule}", validation.ValidationValue); textarea.Attributes.Add($"data-msg-{validation.ValidationRule}", validation.ValidationErrorMessage); } foreach (var item in control.Settings) { AddSettingsHtml(textarea, item); } div.Add(textarea); ExplanationText(control, div); ToolTip(control, textarea); return(div.ToString()); }
public static IHtmlString SubmitButton(this KenticoForm html, string submitText, object htmlAttributes) { var tag = new MultiLevelTag("button"); tag.Attributes.Add("type", "submit"); tag.Attributes.Add("data-submit", null); tag.SetInnerText(submitText); if (htmlAttributes != null) { var customAttributes = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes); if (customAttributes != null) { foreach (var item in customAttributes.Where(item => !tag.Attributes.ContainsKey(item.Key))) { tag.Attributes.Add(item.Key, item.Value.ToString()); } } } tag.AddCssClass("button"); return(MvcHtmlString.Create(tag.ToString())); }