public static string RenderFormGroupDatePicker(HtmlHelper html, DatePickerModel inputModel, LabelModel labelModel)
        {
            var input = RenderControl.RenderDatePicker(html, inputModel);

            var label = RenderControl.RenderLabel(html, labelModel ?? new LabelModel
            {
                htmlFieldName = inputModel.htmlFieldName,
                metadata = inputModel.metadata,
                htmlAttributes = new { @class = "control-label" }.ToDictionary()
            });

            bool fieldIsValid = true;

            if (inputModel != null)
                fieldIsValid = html.ViewData.ModelState.IsValidField(inputModel.htmlFieldName);

            return new FormGroup(input, label, FormGroupType.TextBoxLike, fieldIsValid).ToHtmlString();
        }
        public static HtmlString RenderDatePicker(HtmlHelper html, DatePickerModel model)
        {
            var combinedHtml = "{0}{1}{2}";
            var addOn = new TagBuilder("span");
            var container = new TagBuilder("div");
            var addOnPrependString = "";
            var addOnPrependIcon = "";
            var addOnAppendIcon = "";

            var htmlAttributes = new
            {
                @type = "text"
            }.ObjectToHtmlAttributesDictionary();

            model.htmlAttributes.MergeHtmlAttributes(html.GetUnobtrusiveValidationAttributes(model.htmlFieldName, model.metadata));

            if (!string.IsNullOrEmpty(model.id))
                model.htmlAttributes.Add("id", model.id);

            if (!string.IsNullOrEmpty(model.placeholder))
                model.htmlAttributes.Add("placeholder", model.placeholder);

            if (model.size != Size._NotSet)
                model.htmlAttributes.AddOrMergeCssClass("class", $"input-{model.size.ToName()}");

            model.htmlAttributes.AddOrMergeCssClass("class", "date-picker");
            model.htmlAttributes.AddOrMergeCssClass("class", "form-control");

            if (!string.IsNullOrEmpty(model.dateFormat))
                model.htmlAttributes.AddOrReplace(model.HtmlAttr(() => model.dateFormat), model.dateFormat);

            if (model.weekStart != 0)
                model.htmlAttributes.AddOrReplace(model.HtmlAttr(() => model.weekStart), model.weekStart.ToString());

            if(model.autoclose)
                model.htmlAttributes.AddOrReplace(model.HtmlAttr(() => model.autoclose), model.autoclose.ToString().ToLower());

            if(model.calendarWeeks)
                model.htmlAttributes.AddOrReplace(model.HtmlAttr(() => model.calendarWeeks), model.calendarWeeks.ToString().ToLower());

            if(model.clearBtn)
                model.htmlAttributes.AddOrReplace(model.HtmlAttr(() => model.clearBtn), model.clearBtn.ToString().ToLower());

            if(!string.IsNullOrEmpty(model.container))
                model.htmlAttributes.AddOrReplace(model.HtmlAttr(() => model.container), model.container);

            if(model.datesDisabled.Any())
                model.htmlAttributes.AddOrReplace(model.HtmlAttr(() => model.datesDisabled), new JavaScriptSerializer().Serialize(model.datesDisabled));

            if(model.daysOfWeekDisabled.Any())
                model.htmlAttributes.AddOrReplace(model.HtmlAttr(() => model.daysOfWeekDisabled), new JavaScriptSerializer().Serialize(model.daysOfWeekDisabled));

            if (model.daysOfWeekHighlighted.Any())
                model.htmlAttributes.AddOrReplace(model.HtmlAttr(() => model.daysOfWeekHighlighted), new JavaScriptSerializer().Serialize(model.daysOfWeekHighlighted));

            if (!string.IsNullOrEmpty(model.defaultViewDate))
                model.htmlAttributes.AddOrReplace(model.HtmlAttr(() => model.defaultViewDate), model.defaultViewDate);

            if(model.disableTouchKeyboard)
                model.htmlAttributes.AddOrReplace(model.HtmlAttr(() => model.disableTouchKeyboard), model.disableTouchKeyboard.ToString().ToLower());

            if(!model.enableOnReadonly)
                model.htmlAttributes.AddOrReplace(model.HtmlAttr(() => model.enableOnReadonly), model.enableOnReadonly.ToString().ToLower());

            if (model.endDate != null)
                model.htmlAttributes.AddOrReplace(model.HtmlAttr(() => model.endDate), model.endDate.ToString());

            if(!model.forceParse)
                model.htmlAttributes.AddOrReplace(model.HtmlAttr(() => model.forceParse), model.forceParse.ToString().ToLower());

            if(model.immediateUpdates)
                model.htmlAttributes.AddOrReplace(model.HtmlAttr(() => model.immediateUpdates), model.immediateUpdates.ToString().ToLower());

            if (!model.keyboardNavigation)
                model.htmlAttributes.AddOrReplace(model.HtmlAttr(() => model.keyboardNavigation), model.keyboardNavigation.ToString().ToLower());

            if(!string.IsNullOrEmpty(model.language))
                model.htmlAttributes.AddOrReplace(model.HtmlAttr(() => model.language), model.language);

            if(model.multidate)
                model.htmlAttributes.AddOrReplace(model.HtmlAttr(() => model.multidate), model.multidate.ToString().ToLower());

            if(!string.IsNullOrEmpty(model.multidateSeparator))
                model.htmlAttributes.AddOrReplace(model.HtmlAttr(() => model.multidateSeparator), model.multidateSeparator);

            if(!string.IsNullOrEmpty(model.orientation))
                model.htmlAttributes.AddOrReplace(model.HtmlAttr(() => model.orientation), model.orientation);

            if(!model.showOnFocus)
                model.htmlAttributes.AddOrReplace(model.HtmlAttr(() => model.showOnFocus), model.showOnFocus.ToString().ToLower());

            if(model.startDate != null)
                model.htmlAttributes.AddOrReplace(model.HtmlAttr(() => model.startDate), model.startDate.ToString());

            if(model.startView != 0)
                model.htmlAttributes.AddOrReplace(model.HtmlAttr(() => model.startView), model.startView.ToString());

            if(!string.IsNullOrEmpty(model.title))
                model.htmlAttributes.AddOrReplace(model.HtmlAttr(() => model.title), model.title);

            if(!string.IsNullOrEmpty(model.todayBtn))
                model.htmlAttributes.AddOrReplace(model.HtmlAttr(() => model.todayBtn), model.todayBtn);

            if (model.todayHighlight)
                model.htmlAttributes.AddOrReplace(model.HtmlAttr(() => model.todayHighlight), model.todayHighlight.ToString().ToLower());

            if(model.toggleActive)
                model.htmlAttributes.AddOrReplace(model.HtmlAttr(() => model.toggleActive), model.toggleActive.ToString().ToLower());

            if(model.zIndexOffset != 10)
                model.htmlAttributes.AddOrReplace(model.HtmlAttr(() => model.zIndexOffset), model.zIndexOffset.ToString());

            htmlAttributes.MergeHtmlAttributes(model.htmlAttributes.FormatHtmlAttributes());

            var input = html.TextBox(model.htmlFieldName, model.value, model.format, htmlAttributes).ToHtmlString();

            container.AddOrMergeCssClass("input-group");
            //container.AddOrMergeCssClass("date-picker");
            addOn.AddCssClass("input-group-addon");

            addOn.InnerHtml = new Icon(Icons.Calendar, Size.Lg).ToHtmlString();
            addOnAppendIcon = addOn.ToString();

            if (!string.IsNullOrEmpty(model.prependString) || model.iconPrepend != Icons._not_set || !string.IsNullOrEmpty(model.iconPrependCustomClass))
            {
                if (!string.IsNullOrEmpty(model.prependString))
                {
                    addOn.InnerHtml = model.prependString;
                    addOnPrependString = addOn.ToString();
                }

                if (model.iconPrepend != Icons._not_set)
                {
                    addOn.InnerHtml = new Icon(model.iconPrepend, model.iconPrependIsWhite).ToHtmlString();
                    addOnPrependIcon = addOn.ToString();
                }

                if (!string.IsNullOrEmpty(model.iconPrependCustomClass))
                {
                    var i = new TagBuilder("i");
                    i.AddCssClass(model.iconPrependCustomClass);
                    addOn.InnerHtml = i.ToString(TagRenderMode.Normal);
                    addOnPrependIcon = addOn.ToString();
                }
            }

            container.InnerHtml = addOnPrependIcon + addOnPrependString + "{0}" + addOnAppendIcon;
            combinedHtml = container.ToString(TagRenderMode.Normal) + "{1}{2}";

            var helpText = model.helpText != null ? model.helpText.ToHtmlString() : string.Empty;
            var validationMessage = "";

            if (model.displayValidationMessage)
            {
                var validation = html.ValidationMessage(model.htmlFieldName).ToHtmlString();
                validationMessage = new HelpText(validation, model.validationMessageStyle).ToHtmlString();
            }

            string htmlTextBox = string.Format(combinedHtml, input, helpText, validationMessage);

            TagBuilder inputWrapper = null;

            if (!string.IsNullOrEmpty(model.inputElementWrapper))
            {
                inputWrapper = new TagBuilder(model.inputElementWrapper);

                if (model.inputElementWrapperAttributes != null)
                    inputWrapper.MergeAttributes(HtmlHelper.AnonymousObjectToHtmlAttributes(model.inputElementWrapperAttributes));

                inputWrapper.InnerHtml = htmlTextBox;
            }

            string htmlString = inputWrapper != null
                ? inputWrapper.ToString(TagRenderMode.Normal)
                : htmlTextBox;

            return new HtmlString(htmlString);
        }