From decfa808bbef9adeb11222dc204e58a535813703 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Mon, 16 Aug 2010 11:11:30 -0700 Subject: [PATCH] Change the YesNo form plugin to be a subclass of RadioList. Fix rendering problems with RadioList. Fixes bug #11777 --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/Form/List.pm | 2 +- lib/WebGUI/Form/RadioList.pm | 13 ++++--- lib/WebGUI/Form/YesNo.pm | 72 ++++++++++++++++-------------------- 4 files changed, 40 insertions(+), 48 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index f5211b8bf..e37495e1f 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -3,6 +3,7 @@ - fixed #11781: Thingy wrong retorn value from Ajax method - fixed #11780: fixFilenames regex needs an anchor in ZipArchive asset - fixed #11782: Attachments all showing duplicated first thumbnail + - fixed #11777: Thingy search on yes no field fails 7.9.12 - webgui.org homepage gives 404 (#11778) diff --git a/lib/WebGUI/Form/List.pm b/lib/WebGUI/Form/List.pm index 14d6bde7b..ec9b078b7 100644 --- a/lib/WebGUI/Form/List.pm +++ b/lib/WebGUI/Form/List.pm @@ -52,7 +52,7 @@ sub alignmentSeparator { return "
\n"; } else { - return "    \n"; + return "  "; } } diff --git a/lib/WebGUI/Form/RadioList.pm b/lib/WebGUI/Form/RadioList.pm index fc79ec1a7..2836a00ea 100644 --- a/lib/WebGUI/Form/RadioList.pm +++ b/lib/WebGUI/Form/RadioList.pm @@ -141,13 +141,14 @@ sub toHtml { $checked = 1; } $output .= WebGUI::Form::Radio->new($self->session, { - name=>$self->get('name'), - value=>$key, - extras=>$self->get('extras'), - checked=>$checked, - id=>$self->get('name').$i + name => $self->get('name'), + value => $key, + extras => $self->get('extras'), + checked => $checked, + id => $self->get('name').$i, + label => $options->{$key}, })->toHtml; - $output .= '" . $alignment; + $output .= $alignment; } $output .= ""; return $output; diff --git a/lib/WebGUI/Form/YesNo.pm b/lib/WebGUI/Form/YesNo.pm index 7ddba081e..7127c947b 100644 --- a/lib/WebGUI/Form/YesNo.pm +++ b/lib/WebGUI/Form/YesNo.pm @@ -15,8 +15,7 @@ package WebGUI::Form::YesNo; =cut use strict; -use base 'WebGUI::Form::Control'; -use WebGUI::Form::Radio; +use base 'WebGUI::Form::RadioList'; use WebGUI::International; =head1 NAME @@ -39,6 +38,18 @@ The following methods are specifically available from this class. Check the supe #------------------------------------------------------------------- +=head2 areOptionsSettable ( ) + +Options are predefined for a Yes/No. + +=cut + +sub areOptionsSettable { + return 0; +} + +#------------------------------------------------------------------- + =head2 definition ( [ additionalTerms ] ) See the super class for additional details. @@ -92,6 +103,24 @@ sub getName { #------------------------------------------------------------------- +=head2 getOptions + +Return the options, set to defaults for the Yes/No. These options are not overridable. + +=cut + +sub getOptions { + my $self = shift; + my $i18n = WebGUI::International->new($self->session); + $self->set('options',{ + 1 => $i18n->get(138), + 0 => $i18n->get(139), + }); + return $self->SUPER::getOptions; +} + +#------------------------------------------------------------------- + =head2 getValue ( [ value ] ) If value is present, we will process it, otherwise the superclass will handle the request. @@ -137,44 +166,5 @@ sub isDynamicCompatible { return 1; } -#------------------------------------------------------------------- - -=head2 toHtml ( ) - -Renders a yes/no question field. - -=cut - -sub toHtml { - my $self = shift; - my $i18n = WebGUI::International->new($self->session); - my ($checkYes, $checkNo); - if ($self->getOriginalValue) { - $checkYes = 1; - } else { - $checkNo = 1; - } - 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; -} - 1; -