@@ -16,17 +16,17 @@ public class NopTextAreaTagHelper : TextAreaTagHelper
16
16
17
17
private const string FOR_ATTRIBUTE_NAME = "asp-for" ;
18
18
private const string REQUIRED_ATTRIBUTE_NAME = "asp-required" ;
19
- private const string DISABLED_ATTRIBUTE_NAME = "asp-disabled " ;
19
+ private const string CUSTOM_HTML_ATTRIBUTES = "html-attributes " ;
20
20
21
21
#endregion
22
22
23
23
#region Properties
24
24
25
25
/// <summary>
26
- /// Indicates whether the input is disabled
26
+ /// Custom html attributes
27
27
/// </summary>
28
- [ HtmlAttributeName ( DISABLED_ATTRIBUTE_NAME ) ]
29
- public string IsDisabled { set ; get ; }
28
+ [ HtmlAttributeName ( CUSTOM_HTML_ATTRIBUTES ) ]
29
+ public object CustomHtmlAttributes { set ; get ; }
30
30
31
31
/// <summary>
32
32
/// Indicates whether the field is required
@@ -70,10 +70,16 @@ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutpu
70
70
: "form-control" ;
71
71
output . Attributes . SetAttribute ( "class" , classValue ) ;
72
72
73
- //add disabled attribute
74
- if ( bool . TryParse ( IsDisabled , out var disabled ) && disabled )
75
- output . Attributes . Add ( new TagHelperAttribute ( "disabled" , "disabled" ) ) ;
76
-
73
+ //set custom html attributes
74
+ var htmlAttributesDictionary = HtmlHelper . AnonymousObjectToHtmlAttributes ( CustomHtmlAttributes ) ;
75
+ if ( htmlAttributesDictionary ? . Count > 0 )
76
+ {
77
+ foreach ( var ( key , value ) in htmlAttributesDictionary )
78
+ {
79
+ output . Attributes . Add ( key , value ) ;
80
+ }
81
+ }
82
+
77
83
//additional parameters
78
84
var rowsNumber = output . Attributes . ContainsName ( "rows" ) ? output . Attributes [ "rows" ] . Value : 4 ;
79
85
output . Attributes . SetAttribute ( "rows" , rowsNumber ) ;
0 commit comments