public CheckBoxModel() { htmlAttributes = new Dictionary<string, object>(); CheckBoxType = InputRadioCheckBoxType.Normal; }
/// <summary> /// Checkbox type normal or icon /// </summary> /// <param name="checkBoxType"></param> /// <returns></returns> public CheckBox DisplayType(InputRadioCheckBoxType checkBoxType) { _model.CheckBoxType = checkBoxType; return this; }
/// <summary> /// Type of radio: normal or icon /// </summary> /// <param name="type"></param> /// <returns></returns> public RadioButton DisplayType(InputRadioCheckBoxType type) { _model.RadioType = type; return this; }
public static string RenderInputListItem(HtmlHelper html, InputType inputType, string htmlFieldName, ModelMetadata metadata, int index, string inputValue, string inputText, object inputHtmlAttributes, object labelHtmlAttributes, bool inputIsChecked, bool inputIsDisabled, InputRadioCheckBoxType inputItemType) { var input = string.Empty; var fullHtmlFieldName = html.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(htmlFieldName); var htmlAttrs = labelHtmlAttributes.ToDictionary(); var itemType = "form-icon"; if (inputItemType != InputRadioCheckBoxType._NotSet) itemType = inputItemType.ToName(); switch (inputType) { case InputType._NotSet: break; case InputType.CheckBoxList: { htmlAttrs.AddOrMergeCssClass("class", $"form-checkbox {itemType} form-text").FormatHtmlAttributes(); var checkboxModel = new CheckBoxModel { htmlFieldName = htmlFieldName, value = inputValue, metadata = metadata, htmlAttributes = inputHtmlAttributes.ToDictionary().FormatHtmlAttributes(), id = fullHtmlFieldName.FormatForMvcInputId() + "_" + index, isChecked = inputIsChecked, isDisabled = inputIsDisabled }; input = RenderCheckBoxCustom(html, checkboxModel).ToHtmlString(); break; } case InputType.RadioList: { htmlAttrs.AddOrMergeCssClass("class", $"form-radio {itemType} form-text").FormatHtmlAttributes(); var radiobuttonModel = new RadioButtonModel { htmlFieldName = htmlFieldName, value = inputValue, metadata = metadata, htmlAttributes = inputHtmlAttributes.ToDictionary().FormatHtmlAttributes(), id = fullHtmlFieldName.FormatForMvcInputId() + "_" + index, isChecked = inputIsChecked, isDisabled = inputIsDisabled }; input = RenderRadioButton(html, radiobuttonModel).ToHtmlString(); break; } default: break; } var labelModel = new LabelModel { index = index, htmlFieldName = htmlFieldName, labelText = inputText, metadata = metadata, htmlAttributes = htmlAttrs, innerInput = MvcHtmlString.Create(input), showRequiredStar = false }; var labeledInput = RenderLabel(html, labelModel).ToHtmlString(); return labeledInput; }