From 4fe157038004c5020f80e3cfce81d8193061e86e Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Thu, 24 Feb 2011 09:45:48 +0100 Subject: [PATCH] =?utf8?q?options=5Ffor=5Fselect:=20Default=20"0"=20erm?= =?utf8?q?=C3=B6glichen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Template/Plugin/L.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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); } -- 2.20.1