protected override void BootstrapProcess(TagHelperContext context, TagHelperOutput output) { output.TagName = "p"; output.AddCssClass("form-control-static"); if (this.FormGroupContext != null) { this.FormGroupContext.WrapInDivForHorizontalForm(output, !string.IsNullOrEmpty(this.Label)); } else if (this.FormContext != null) { this.FormContext.WrapInDivForHorizontalForm(output, !string.IsNullOrEmpty(this.Label)); } if (!string.IsNullOrEmpty(this.Label)) { output.PreElement.Prepend(LabelTagHelper.GenerateLabel(this.Label, this.FormContext)); } if (!string.IsNullOrEmpty(this.HelpText)) { output.PostElement.PrependHtml(HelpBlockTagHelper.GenerateHelpBlock(this.HelpText)); } if (this.Size != null && this.Size != BootstrapTagHelpers.Size.Default) { output.AddCssClass("input-" + this.Size.Value.GetDescription()); } }
protected override void BootstrapProcess(TagHelperContext context, TagHelperOutput output) { output.TagName = "p"; output.AddCssClass("form-control-static"); if (!string.IsNullOrEmpty(Label)) { output.PreElement.Prepend(LabelTagHelper.GenerateLabel(Label, FormContext)); } if (FormGroupContext != null) { FormGroupContext.WrapInDivForHorizontalForm(output, !string.IsNullOrEmpty(Label)); } else if (FormContext != null) { FormContext.WrapInDivForHorizontalForm(output, !string.IsNullOrEmpty(Label)); } }
private void ProcessNonCheckControl(TagHelperOutput output) { output.AddCssClass("form-control"); if (!string.IsNullOrEmpty(PostAddonText) || !string.IsNullOrEmpty(PreAddonText)) { if ((Size ?? BootstrapTagHelpers.Size.Default) != BootstrapTagHelpers.Size.Default) { var size = Size == BootstrapTagHelpers.Size.Large ? BootstrapTagHelpers.Size.Large : BootstrapTagHelpers.Size.Small; output.PreElement.PrependHtml($"<div class=\"input-group input-group-{size.GetDescription()}\">"); } else { output.PreElement.PrependHtml("<div class=\"input-group\">"); } if (!string.IsNullOrEmpty(PreAddonText)) { output.PreElement.AppendHtml(AddonTagHelper.GenerateAddon(PreAddonText)); } if (!string.IsNullOrEmpty(PostAddonText)) { output.PostElement.AppendHtml(AddonTagHelper.GenerateAddon(PostAddonText)); } output.PostElement.AppendHtml("</div>"); } else if (Size != null && Size != BootstrapTagHelpers.Size.Default) { output.AddCssClass("input-" + Size.Value.GetDescription()); } if (!string.IsNullOrEmpty(HelpText)) { if (InputGroupContext != null) { InputGroupContext.Output.PostElement.PrependHtml(HelpBlockTagHelper.GenerateHelpBlock(HelpText)); } else { output.PostElement.AppendHtml(HelpBlockTagHelper.GenerateHelpBlock(HelpText)); } } if (InputGroupContext == null) { if (FormGroupContext != null) { FormGroupContext.WrapInDivForHorizontalForm(output, !string.IsNullOrEmpty(Label)); } else if (FormContext != null) { FormContext.WrapInDivForHorizontalForm(output, !string.IsNullOrEmpty(Label)); } } if (!string.IsNullOrEmpty(Label)) { if (InputGroupContext == null) { output.PreElement.Prepend(LabelTagHelper.GenerateLabel(Label, Id, FormContext)); } else { InputGroupContext.Output.PreElement.Prepend( LabelTagHelper.GenerateLabel( Label, Id, FormContext)); } } if (FormGroupContext != null && FormGroupContext.HasFeedback && FormGroupContext.ValidationContext != null) { string cssClass; string srText; switch (FormGroupContext.ValidationContext.Value) { case ValidationContext.Success: cssClass = "ok"; srText = Ressources.ValidationSuccess; break; case ValidationContext.Warning: cssClass = "warning-sign"; srText = Ressources.ValidationWarning; break; case ValidationContext.Error: cssClass = "remove"; srText = Ressources.ValidationError; break; default: throw new ArgumentOutOfRangeException(); } output.PostElement.PrependHtml( $"<span class=\"glyphicon glyphicon-{cssClass} form-control-feedback\" aria-hidden=\"true\"></span>"); output.PostElement.PrependHtml($"<span class=\"sr-only\">({srText})</span>"); } }