From 6e57405a90501acf11bf7c2168af8fe90dac2133 Mon Sep 17 00:00:00 2001 From: yekalkan Date: Tue, 1 May 2018 15:00:19 +0300 Subject: [PATCH] Added text-danger class to asp-validation-for tag --- .../TagHelpers/AbpTagHelperService.cs | 9 --------- .../Form/AbpValidationAttributeTagHelper.cs | 18 +++++++++++++++++ .../AbpValidationAttributeTagHelperService.cs | 20 +++++++++++++++++++ 3 files changed, 38 insertions(+), 9 deletions(-) create mode 100644 src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpValidationAttributeTagHelper.cs create mode 100644 src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpValidationAttributeTagHelperService.cs diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/AbpTagHelperService.cs b/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/AbpTagHelperService.cs index f668d3faac..df9c90f3b2 100644 --- a/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/AbpTagHelperService.cs +++ b/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/AbpTagHelperService.cs @@ -101,14 +101,5 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers }); } } - - protected virtual string GetFormInputGroupAsHtml(TagHelperContext context, TagHelperOutput output) - { - var inputTag = GetInputTag(context, out var isCheckbox); - var inputHtml = RenderTagHelperOutput(inputTag, _encoder); - var label = GetLabelAsHtml(inputTag, isCheckbox); - - return GetContent(label, inputHtml, isCheckbox); - } } } \ No newline at end of file diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpValidationAttributeTagHelper.cs b/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpValidationAttributeTagHelper.cs new file mode 100644 index 0000000000..99c9fc4cce --- /dev/null +++ b/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpValidationAttributeTagHelper.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; +using Microsoft.AspNetCore.Mvc.Rendering; +using Microsoft.AspNetCore.Mvc.ViewFeatures; +using Microsoft.AspNetCore.Razor.TagHelpers; +using Volo.Abp.DependencyInjection; + +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form +{ + [HtmlTargetElement(Attributes = "asp-validation-for")] + public class AbpValidationAttributeTagHelper : AbpTagHelper, ITransientDependency + { + public AbpValidationAttributeTagHelper(AbpValidationAttributeTagHelperService tagHelperService) + : base(tagHelperService) + { + + } + } +} diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpValidationAttributeTagHelperService.cs b/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpValidationAttributeTagHelperService.cs new file mode 100644 index 0000000000..0c78cf5396 --- /dev/null +++ b/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpValidationAttributeTagHelperService.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.Encodings.Web; +using Localization.Resources.AbpUi; +using Microsoft.AspNetCore.Mvc.TagHelpers; +using Microsoft.AspNetCore.Mvc.ViewFeatures; +using Microsoft.AspNetCore.Razor.TagHelpers; +using Microsoft.Extensions.Localization; + +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form +{ + public class AbpValidationAttributeTagHelperService : AbpTagHelperService + { + public override void Process(TagHelperContext context, TagHelperOutput output) + { + output.Attributes.Add("class","text-danger"); + } + } +} \ No newline at end of file