From 07f5a9f788d3f06da4cad4bfdc24f28f81494372 Mon Sep 17 00:00:00 2001 From: Aaron Trevena Date: Mon, 30 Oct 2006 18:00:15 +0000 Subject: [PATCH] another stringify fix in AsForm git-svn-id: http://svn.maypole.perl.org/Maypole/trunk@539 48953598-375a-da11-a14b-00016c27c3ee --- lib/Maypole/Model/CDBI/AsForm.pm | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/Maypole/Model/CDBI/AsForm.pm b/lib/Maypole/Model/CDBI/AsForm.pm index 76003ff..b8e4e91 100644 --- a/lib/Maypole/Model/CDBI/AsForm.pm +++ b/lib/Maypole/Model/CDBI/AsForm.pm @@ -1177,7 +1177,7 @@ sub _options_from_objects { my @res; for my $object (@$items) { - $stringify ||= $object->stringify_column; + $stringify ||= $object->stringify_column if ($object->can('stringify_column')); my $id = $object->id; my $opt = HTML::Element->new("option", value => $id); $id =~ s/^0*//; # leading zeros no good in hash key @@ -1194,7 +1194,8 @@ sub _options_from_arrays { my $selected = $args->{selected} || {}; my @res; my $class = $args->{class} || ''; - my $stringify = $args->{stringify} || $self->stringify_column; + my $stringify = $args->{stringify}; + $stringify ||= $self->stringify_column if ($self->can('stringify_column')); for my $item (@$items) { my @pks; # for future multiple key support push @pks, shift @$item foreach $class->columns('Primary'); @@ -1251,7 +1252,8 @@ sub _options_from_hashes { my $selected = $args->{selected} || {}; my $pk = eval {$args->{class}->primary_column} || 'id'; my $fclass = $args->{class} || ''; - my $stringify = $args->{stringify} || $self->stringify_column; + my $stringify = $args->{stringify}; + $stringify ||= $self->stringify_column if ( $self->can('stringify_column') ); my @res; for my $item (@$items) { my $val = defined $item->{$pk} ? $item->{$pk} : ''; @@ -1264,7 +1266,8 @@ sub _options_from_hashes { $content = $item->{$stringify}; } else { $content = join(' ', map {$item->{$_} } keys %$item); - } + } + $opt->push_content( $content ); push @res, $opt; } -- 2.39.5