When using HTML::Widget Filters for form fields that have no value the
following errors are generated:
Use of uninitialized value in substitution (s///) at
/site/catalyst/default/lib/HTML/Widget/Filter/TrimEdges.pm line 27.
Use of uninitialized value in substitution (s///) at
/site/catalyst/default/lib/HTML/Widget/Filter/TrimEdges.pm line 28.
Before passing a parameter value to the actual filter it should first be
checked that it is defined.
Inside HTML::Widget::Filter
sub process {
my ( $self, $params ) = @_;
my @names = scalar @{ $self->names } ? @{ $self->names } : keys
%$params;
for my $name (@names) {
my $values = $params->{$name};
if ( ref $values eq 'ARRAY' ) {
$params->{$name} = [ map { $self->filter($_); } @$values ];
}
else {
$params->{$name} = $self->filter($values);
}
}
}
should be something like:
sub process {
my ( $self, $params ) = @_;
my @names = scalar @{ $self->names } ? @{ $self->names } : keys
%$params;
for my $name (@names) {
if (exists($params->{$name}) && defined($params->{$name})) {
my $values = $params->{$name};
if ( ref $values eq 'ARRAY' ) {
$params->{$name} = [ map { $self->filter($_); } @$values ];
}
else {
$params->{$name} = $self->filter($values);
}
}
}
}