From: Moritz Bunkus Date: Thu, 24 Feb 2011 08:45:48 +0000 (+0100) Subject: options_for_select: Default "0" ermöglichen X-Git-Tag: release-2.6.3~74 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=4fe157038004c5020f80e3cfce81d8193061e86e;p=kivitendo-erp.git options_for_select: Default "0" ermöglichen --- diff --git a/SL/Template/Plugin/L.pm b/SL/Template/Plugin/L.pm index 9995722e1..513f4a221 100644 --- a/SL/Template/Plugin/L.pm +++ b/SL/Template/Plugin/L.pm @@ -207,7 +207,7 @@ sub options_for_select { my $value_title_sub = $options{value_title_sub}; - my %selected = map { ( $_ => 1 ) } @{ ref($options{default}) eq 'ARRAY' ? $options{default} : $options{default} ? [ $options{default} ] : [] }; + my %selected = map { ( $_ => 1 ) } @{ ref($options{default}) eq 'ARRAY' ? $options{default} : defined($options{default}) ? [ $options{default} ] : [] }; my $access = sub { my ($element, $index, $key, $sub) = @_; @@ -231,7 +231,7 @@ sub options_for_select { my $code = ''; foreach my $result (@elements) { my %attributes = ( value => $result->[0] ); - $attributes{selected} = 'selected' if $selected{ $result->[0] || '' }; + $attributes{selected} = 'selected' if $selected{ defined($result->[0]) ? $result->[0] : '' }; $code .= $self->html_tag('option', _H($result->[1]), %attributes); }