Browse Source

Add AutoFocus to AbpInputTagHelper

pull/301/head
Halil İbrahim Kalkan 8 years ago
parent
commit
3b6a75b24f
  1. 2
      src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpInputTagHelper.cs
  2. 7
      src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpInputTagHelperService.cs

2
src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpInputTagHelper.cs

@ -13,6 +13,8 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
[HtmlAttributeName("disabled")]
public bool IsDisabled { get; set; }
public bool AutoFocus { get; set; }
[HtmlAttributeNotBound]
[ViewContext]
public ViewContext ViewContext { get; set; }

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

@ -96,11 +96,16 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
var inputTagHelperOutput = GetInnerTagHelper(new TagHelperAttributeList(), context, inputTagHelper, "input");
if (!inputTagHelperOutput.Attributes.ContainsName("disabled") && TagHelper.IsDisabled)
if (TagHelper.IsDisabled && !inputTagHelperOutput.Attributes.ContainsName("disabled"))
{
inputTagHelperOutput.Attributes.Add("disabled", "true");
}
if (TagHelper.AutoFocus && !inputTagHelperOutput.Attributes.ContainsName("data-auto-focus"))
{
inputTagHelperOutput.Attributes.Add("data-auto-focus", "true");
}
isCheckbox = IsInputCheckbox(context, output, inputTagHelperOutput.Attributes);
inputTagHelperOutput.Attributes.AddClass(isCheckbox ? "form-check-input" : "form-control");

Loading…
Cancel
Save