Skip to content

Commit

Permalink
Adding max length option to textboxes
Browse files Browse the repository at this point in the history
  • Loading branch information
barthamark committed Oct 31, 2024
1 parent d91efab commit c1a1b5a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Lombiq.UIKit/TagHelpers/EditorTagHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ public class EditorTagHelper : BaseShapeTagHelper
[HtmlAttributeName(nameof(InputClasses))]
public string InputClasses { get; set; }

[HtmlAttributeName(nameof(MaxLength))]
public int MaxLength { get; set; }

// Otherwise the taghelper can't bind its value to it.
#pragma warning disable CA2227 // Collection properties should be read only
#pragma warning disable MA0016 // Prefer return collection abstraction instead of implementation
Expand Down
5 changes: 5 additions & 0 deletions Lombiq.UIKit/Views/UiKit-Editor-Textbox.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@
inputAttributes["placeholder"] = placeholder;
}

if (Model.MaxLength is int maxLength)
{
inputAttributes["maxlength"] = maxLength;
}

var noLabelAndNotRequired = Model.LabelPosition == LabelPosition.None && !isRequired;
var label = noLabelAndNotRequired
? null
Expand Down

0 comments on commit c1a1b5a

Please sign in to comment.