From 6f89eb4bc17949c9a15b13451775c3980f7462de Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Mon, 31 Oct 2005 05:04:26 +0000 Subject: [PATCH] pull if statement out of for loop --- lib/WebGUI/Form/CheckList.pm | 14 ++++++++------ lib/WebGUI/Form/RadioList.pm | 14 ++++++++------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/lib/WebGUI/Form/CheckList.pm b/lib/WebGUI/Form/CheckList.pm index 7500e8ccd..b1435bf77 100644 --- a/lib/WebGUI/Form/CheckList.pm +++ b/lib/WebGUI/Form/CheckList.pm @@ -119,6 +119,13 @@ Renders a series of checkboxes. sub toHtml { my $self = shift; my $output; + my $alignment; + if ($self->{vertical}) { + $alignment = "
\n"; + } + else { + $alignment = "    \n"; + } foreach my $key (keys %{$self->{options}}) { my $checked = 0; foreach my $item (@{$self->{value}}) { @@ -132,12 +139,7 @@ sub toHtml { extras=>$self->{extras}, checked=>$checked })->toHtml; - $output .= ${$self->{options}}{$key}; - if ($self->{vertical}) { - $output .= "
\n"; - } else { - $output .= "    \n"; - } + $output .= ${$self->{options}}{$key} . $alignment; } return $output; } diff --git a/lib/WebGUI/Form/RadioList.pm b/lib/WebGUI/Form/RadioList.pm index 7b2e813f2..1262bb1c0 100644 --- a/lib/WebGUI/Form/RadioList.pm +++ b/lib/WebGUI/Form/RadioList.pm @@ -97,6 +97,13 @@ Renders a series of radio buttons. sub toHtml { my $self = shift; my $output; + my $alignment; + if ($self->{vertical}) { + $alignment = "
\n"; + } + else { + $alignment = "    \n"; + } foreach my $key (keys %{$self->{options}}) { my $checked = 0; if ($self->{value} eq $key) { @@ -108,12 +115,7 @@ sub toHtml { extras=>$self->{extras}, checked=>$checked })->toHtml; - $output .= ${$self->{options}}{$key}; - if ($self->{vertical}) { - $output .= "
\n"; - } else { - $output .= "    \n"; - } + $output .= ${$self->{options}}{$key} . $alignment; } return $output; }