|
|
|
|
@ -1,5 +1,9 @@
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Text.Encodings.Web;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc.TagHelpers;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
|
|
|
|
using Microsoft.AspNetCore.Razor.TagHelpers;
|
|
|
|
|
using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers;
|
|
|
|
|
|
|
|
|
|
@ -7,11 +11,44 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
|
|
|
|
|
{
|
|
|
|
|
public class AbpInputTagHelperService : AbpTagHelperService<AbpInputTagHelper>
|
|
|
|
|
{
|
|
|
|
|
private readonly HtmlEncoder _htmlEncoder;
|
|
|
|
|
private readonly IHtmlGenerator _generator;
|
|
|
|
|
|
|
|
|
|
public AbpInputTagHelperService(HtmlEncoder htmlEncoder, IHtmlGenerator generator)
|
|
|
|
|
{
|
|
|
|
|
_htmlEncoder = htmlEncoder;
|
|
|
|
|
_generator = generator;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Process(TagHelperContext context, TagHelperOutput output)
|
|
|
|
|
{
|
|
|
|
|
output.TagName = "input";
|
|
|
|
|
output.Attributes.AddClass("form-control");
|
|
|
|
|
output.TagMode = TagMode.SelfClosing;
|
|
|
|
|
|
|
|
|
|
ProcessAttributes(output);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual void ProcessAttributes(TagHelperOutput output)
|
|
|
|
|
{
|
|
|
|
|
var inputTagHelperOutput = GetAttributes();
|
|
|
|
|
|
|
|
|
|
foreach (var tagHelperAttribute in inputTagHelperOutput.Attributes)
|
|
|
|
|
{
|
|
|
|
|
output.Attributes.Add(tagHelperAttribute);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
output.Attributes.RemoveAll("asp-for");
|
|
|
|
|
output.Attributes.Add("class", "form-control");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual TagHelperOutput GetAttributes()
|
|
|
|
|
{
|
|
|
|
|
var inputTagHelper = new InputTagHelper(_generator)
|
|
|
|
|
{
|
|
|
|
|
For = TagHelper.AspFor,
|
|
|
|
|
ViewContext = TagHelper.ViewContext
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return GetInnerTagHelper(new TagHelperAttributeList(), inputTagHelper);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|