From 98bfd9ac1d5b354f419c848732dfeeff0bc003e8 Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Tue, 16 Sep 2008 16:27:15 +0000 Subject: [PATCH] added fieldsets around form controls with multiple elements --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/Form/CheckList.pm | 4 ++-- lib/WebGUI/Form/Radio.pm | 13 ++++++++++--- lib/WebGUI/Form/RadioList.pm | 5 +++-- lib/WebGUI/Form/YesNo.pm | 37 +++++++++++++++++++----------------- 5 files changed, 36 insertions(+), 24 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 94137b5eb..215965edd 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -1,4 +1,5 @@ 7.6.0 + - added fieldsets around form controls with multiple elements - rfe: Town Hall: Menu title in search results - rfe: Process Macros in HTTP Proxy's URL - rfe: TimeZone for the User Profiles displays incorrectly after installation diff --git a/lib/WebGUI/Form/CheckList.pm b/lib/WebGUI/Form/CheckList.pm index 6959081a8..3c6a9a4f7 100644 --- a/lib/WebGUI/Form/CheckList.pm +++ b/lib/WebGUI/Form/CheckList.pm @@ -137,7 +137,7 @@ Renders a series of checkboxes. sub toHtml { my $self = shift; - my $output; + my $output = '
'; my $alignment = $self->alignmentSeparator; # Add the select all button @@ -164,7 +164,7 @@ sub toHtml { . $alignment ; } - + $output .= "
"; return $output; } diff --git a/lib/WebGUI/Form/Radio.pm b/lib/WebGUI/Form/Radio.pm index e778c9933..9f18ce308 100644 --- a/lib/WebGUI/Form/Radio.pm +++ b/lib/WebGUI/Form/Radio.pm @@ -59,7 +59,10 @@ sub definition { push(@{$definition}, { checked=>{ defaultValue=> 0 - }, + }, + label => { + defaultValue => undef, + }, }); return $class->SUPER::definition($session, $definition); } @@ -99,12 +102,16 @@ Renders and input tag of type radio. =cut sub toHtml { - my$self = shift; + my $self = shift; my $value = $self->getOriginalValue(); $value = defined $value ? $self->fixMacros($self->fixQuotes($self->fixSpecialCharacters($value))) : ''; my $checkedText = $self->get("checked") ? ' checked="checked"' : ''; my $idText = $self->get('id') ? ' id="'.$self->get('id').'" ' : ''; - return 'get("extras")||'').' />'; + my $control = 'get("extras")||'').' />'; + if ($self->get('label')) { + return ""; + } + return $control; } diff --git a/lib/WebGUI/Form/RadioList.pm b/lib/WebGUI/Form/RadioList.pm index 6f9c891c4..5aadf0dde 100644 --- a/lib/WebGUI/Form/RadioList.pm +++ b/lib/WebGUI/Form/RadioList.pm @@ -143,7 +143,7 @@ Renders a series of radio buttons. sub toHtml { my $self = shift; - my $output; + my $output = '
'; my $alignment = $self->alignmentSeparator; my $i=0; my $options = $self->getOptions; @@ -160,8 +160,9 @@ sub toHtml { checked=>$checked, id=>$self->get('name').$i })->toHtml; - $output .= '" . $alignment; + $output .= '" . $alignment; } + $output .= "
"; return $output; } diff --git a/lib/WebGUI/Form/YesNo.pm b/lib/WebGUI/Form/YesNo.pm index 2f334f72d..0ce827a9d 100644 --- a/lib/WebGUI/Form/YesNo.pm +++ b/lib/WebGUI/Form/YesNo.pm @@ -150,25 +150,28 @@ sub toHtml { my $i18n = WebGUI::International->new($self->session); my ($checkYes, $checkNo); if ($self->getOriginalValue) { - $checkYes = 1; + $checkYes = 1; } else { - $checkNo = 1; + $checkNo = 1; } - my $output = WebGUI::Form::Radio->new($self->session, - checked=>$checkYes, - name=>$self->get("name"), - value=>1, - extras=>$self->get("extras") - )->toHtml; - $output .= $i18n->get(138); - $output .= '   '; - $output .= WebGUI::Form::Radio->new($self->session, - checked=>$checkNo, - name=>$self->get("name"), - value=>0, - extras=>$self->get("extras") - )->toHtml; - $output .= $i18n->get(139); + my $output = '
' + . WebGUI::Form::Radio->new($self->session, + checked => $checkYes, + name => $self->get("name"), + value => 1, + extras => $self->get("extras"), + label => $i18n->get(138), + )->toHtml + . '   ' + . WebGUI::Form::Radio->new($self->session, + checked => $checkNo, + name => $self->get("name"), + value => 0, + extras => $self->get("extras"), + label => $i18n->get(139), + )->toHtml + . '
' + ; return $output; }