From 7fc89b3fb93cbe6f9f92ce4e82c1e3c097c16c9e Mon Sep 17 00:00:00 2001 From: Dave Roberts Date: Wed, 27 May 2026 14:27:27 +0100 Subject: [PATCH 1/5] Add max_length to string column --- lib/GADS/Column/String.pm | 23 ++++++++++++++++++++- lib/GADS/Role/Presentation/Column/String.pm | 3 ++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/lib/GADS/Column/String.pm b/lib/GADS/Column/String.pm index 9e9e014f7..86c12a1be 100644 --- a/lib/GADS/Column/String.pm +++ b/lib/GADS/Column/String.pm @@ -20,12 +20,33 @@ package GADS::Column::String; use Log::Report 'linkspace'; use Moo; -use MooX::Types::MooseLike::Base qw/Bool Str Maybe/; +use MooX::Types::MooseLike::Base qw/Bool Str Int Maybe/; extends 'GADS::Column'; with 'GADS::Role::Presentation::Column::String'; +has '+option_names' => ( + default => sub { + [+{ + name => 'max_length', + user_configurable => 1, + }] + } +); + +has max_length => ( + is => 'rw', + isa => Maybe[Int], + lazy => 1, + builder => sub { + my $self = shift; + $self->has_options ? $self->options->{max_length} // undef : undef; # explicitly return undef if no options, to avoid confusion with 0 + }, + trigger => sub { $_[0]->reset_options }, + coerce => sub { defined $_[0] && $_[0] ne "" && $_[0] =~ /^\d+$/i ? int($_[0]) : undef }, +); + has textbox => ( is => 'rw', isa => Bool, diff --git a/lib/GADS/Role/Presentation/Column/String.pm b/lib/GADS/Role/Presentation/Column/String.pm index b89e349bd..6f14132ed 100644 --- a/lib/GADS/Role/Presentation/Column/String.pm +++ b/lib/GADS/Role/Presentation/Column/String.pm @@ -5,7 +5,8 @@ use Moo::Role; sub after_presentation { my ($self, $return) = @_; - $return->{textbox} = $self->textbox; + $return->{textbox} = $self->textbox; + $return->{max_length} = $self->max_length if defined $self->max_length; } 1; From c0c05ab96afac252034a031597d9ee70766ecd2c Mon Sep 17 00:00:00 2001 From: Dave Roberts Date: Wed, 27 May 2026 14:28:23 +0100 Subject: [PATCH 2/5] Updated views to add max length --- views/edit.tt | 12 ++++++++---- views/fields/input.tt | 1 + views/fields/multi_field.tt | 6 ++++-- views/fields/textarea.tt | 1 + views/layout.tt | 14 ++++++++++++++ 5 files changed, 28 insertions(+), 6 deletions(-) diff --git a/views/edit.tt b/views/edit.tt index e99bceac4..7ac1db93b 100755 --- a/views/edit.tt +++ b/views/edit.tt @@ -1025,7 +1025,8 @@ popover_body = col.helptext_html filter = "html" is_required = field_is_required - is_readonly = readonly; + is_readonly = readonly + max_length = col.max_length; ELSE; INCLUDE fields/textarea.tt id = col.id @@ -1039,7 +1040,8 @@ is_required = field_is_required is_readonly = readonly hide_group = 1 - rows = 10; + rows = 10 + max_length = col.max_length; END; ELSE; field_input_type = "text"; @@ -1079,7 +1081,8 @@ filter = "html" is_required = field_is_required is_readonly = readonly - type = field_input_type; + type = field_input_type + max_length = col.max_length; ELSE; INCLUDE fields/input.tt id = col.id @@ -1096,7 +1099,8 @@ is_required = field_is_required is_readonly = readonly hide_group = 1 - type = field_input_type; + type = field_input_type + max_length = col.max_length; END; diff --git a/views/fields/input.tt b/views/fields/input.tt index 688b70521..ea827fb2a 100644 --- a/views/fields/input.tt +++ b/views/fields/input.tt @@ -64,6 +64,7 @@ readonly[% END %][% IF is_required %] required aria-required="true"[% END %] + [% IF max_length %] data-max="[% max_length %]"[% END %] > diff --git a/views/fields/multi_field.tt b/views/fields/multi_field.tt index 40c86f5e6..51ae32b98 100644 --- a/views/fields/multi_field.tt +++ b/views/fields/multi_field.tt @@ -96,7 +96,8 @@ is_readonly = is_readonly hide_group = 1 multi_value_style = 1 - rows = 10; + rows = 10 + max_length = max_length; ELSE; INCLUDE fields/input.tt id = id @@ -112,7 +113,8 @@ is_required = is_required is_readonly = is_readonly hide_group = 1 - type = field_input_type; + type = field_input_type + max_length = max_length; END; %]