From 985b45212a177a548338881d422ccf21681c6ccf Mon Sep 17 00:00:00 2001 From: JT Smith Date: Wed, 14 Aug 2002 02:18:39 +0000 Subject: [PATCH] Fixed a couple of bugs with the checkbox element --- lib/WebGUI/HTMLForm.pm | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/lib/WebGUI/HTMLForm.pm b/lib/WebGUI/HTMLForm.pm index affbc0938..1bd3e67de 100644 --- a/lib/WebGUI/HTMLForm.pm +++ b/lib/WebGUI/HTMLForm.pm @@ -124,16 +124,17 @@ sub _tableFormRow { =cut sub checkbox { - my ($subtext, $class, $output, $name, $label, $extras, $checked, $value); + my ($subtext, $checkedText, $class, $output, $name, $label, $extras, $checked, $value); $class = shift; $name = shift; $label = shift; $checked = shift; - $checked = ' checked="1"' if ($checked); + $checkedText = ' checked="1"' if ($checked); $subtext = shift; - $value = shift || 1; + $value = shift; + $value = 1 if ($value eq ""); $extras = shift; - $output = ''; + $output = ''; $output .= _subtext($subtext); $output = _tableFormRow($label,$output) unless ($class->{_noTable}); $class->{_data} .= $output; @@ -1024,7 +1025,7 @@ sub printRowsOnly { #------------------------------------------------------------------- -=head2 radio ( name [ label, checked, subtext, value, extras ] ) +=head2 radio ( name [ label, checked, value, subtext, extras ] ) Adds a radio button row to this form. @@ -1040,15 +1041,15 @@ sub printRowsOnly { If you'd like this radio button to be defaultly checked, set this to "1". +=item value + + The default value for this form element. + =item subtext Extra text to describe this form element or to provide special instructions. -=item value - - The default value for this form element. Defaults to "1". - =item extras If you want to add anything special to this form element like @@ -1060,16 +1061,16 @@ sub printRowsOnly { =cut sub radio { - my ($subtext, $class, $output, $name, $label, $extras, $checked, $value); + my ($subtext, $checkedText, $class, $output, $name, $label, $extras, $checked, $value); $class = shift; $name = shift; $label = shift; $checked = shift; - $checked = ' checked="1"' if ($checked); + $checkedText = ' checked="1"' if ($checked); + $value = shift; $subtext = shift; - $value = shift || 1; $extras = shift; - $output = ''; + $output = ''; $output .= _subtext($subtext); $output = _tableFormRow($label,$output) unless ($class->{_noTable}); $class->{_data} .= $output;