pull if statement out of for loop

This commit is contained in:
Colin Kuskie 2005-10-31 05:04:26 +00:00
parent 903ccd0777
commit 6f89eb4bc1
2 changed files with 16 additions and 12 deletions

View file

@ -119,6 +119,13 @@ Renders a series of checkboxes.
sub toHtml {
my $self = shift;
my $output;
my $alignment;
if ($self->{vertical}) {
$alignment = "<br />\n";
}
else {
$alignment = " &nbsp; &nbsp;\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 .= "<br />\n";
} else {
$output .= " &nbsp; &nbsp;\n";
}
$output .= ${$self->{options}}{$key} . $alignment;
}
return $output;
}

View file

@ -97,6 +97,13 @@ Renders a series of radio buttons.
sub toHtml {
my $self = shift;
my $output;
my $alignment;
if ($self->{vertical}) {
$alignment = "<br />\n";
}
else {
$alignment = " &nbsp; &nbsp;\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 .= "<br />\n";
} else {
$output .= " &nbsp; &nbsp;\n";
}
$output .= ${$self->{options}}{$key} . $alignment;
}
return $output;
}