X-Git-Url: https://git.decadent.org.uk/gitweb/?p=maypole.git;a=blobdiff_plain;f=lib%2FMaypole%2FModel%2FCDBI%2FAsForm.pm;h=b8e4e91a483191f424d6d6ac203f0bdb63351196;hp=76003ff3cf811d4ea1e44c053a98ef12897ccee7;hb=07f5a9f788d3f06da4cad4bfdc24f28f81494372;hpb=4f4bbd04570ff3c5f59f99c5cbf868d9b1a3da49 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; }