Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FOLK-224: Adding max length option to textboxes #66

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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