Browse Source

Avoid classes if input is hidden

pull/19129/head
Rafael Gonzales 3 years ago
parent
commit
f2591e9c5b
  1. 29
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpInputTagHelperService.cs

29
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpInputTagHelperService.cs

@ -54,19 +54,22 @@ public class AbpInputTagHelperService : AbpTagHelperService<AbpInputTagHelper>
output.TagMode = TagMode.StartTagAndEndTag; output.TagMode = TagMode.StartTagAndEndTag;
output.TagName = "div"; output.TagName = "div";
LeaveOnlyGroupAttributes(context, output); LeaveOnlyGroupAttributes(context, output);
if (TagHelper.FloatingLabel && !isCheckBox) if (!IsOutputHidden(output))
{ {
output.Attributes.AddClass("form-floating"); if (TagHelper.FloatingLabel && !isCheckBox)
} {
if (TagHelper.AddMarginBottomClass) output.Attributes.AddClass("form-floating");
{ }
output.Attributes.AddClass(isCheckBox ? "mb-2" : "mb-3"); if (TagHelper.AddMarginBottomClass)
} {
if (isCheckBox) output.Attributes.AddClass(isCheckBox ? "mb-2" : "mb-3");
{ }
output.Attributes.AddClass("custom-checkbox"); if (isCheckBox)
output.Attributes.AddClass("custom-control"); {
output.Attributes.AddClass("form-check"); output.Attributes.AddClass("custom-checkbox");
output.Attributes.AddClass("custom-control");
output.Attributes.AddClass("form-check");
}
} }
output.Content.AppendHtml(innerHtml); output.Content.AppendHtml(innerHtml);
} }
@ -263,7 +266,7 @@ public class AbpInputTagHelperService : AbpTagHelperService<AbpInputTagHelper>
} }
protected virtual async Task<string> GetLabelAsHtmlAsync(TagHelperContext context, TagHelperOutput output, TagHelperOutput inputTag, bool isCheckbox) protected virtual async Task<string> GetLabelAsHtmlAsync(TagHelperContext context, TagHelperOutput output, TagHelperOutput inputTag, bool isCheckbox)
{ {
if (IsOutputHidden(inputTag) || TagHelper.SuppressLabel) if (IsOutputHidden(inputTag) || TagHelper.SuppressLabel)
{ {
return string.Empty; return string.Empty;

Loading…
Cancel
Save