From a300ce8194fc96fea04a161a7b1a3b7c8e95c729 Mon Sep 17 00:00:00 2001 From: Kaleb Murphy Date: Thu, 7 Aug 2008 19:21:12 +0000 Subject: [PATCH] Layout can now uncheck all hidden assets. CheckList now has its own getValue which does not call getDefaultValue. --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/Form/CheckList.pm | 35 +++++++++++++++++++++++++++++++++++ t/Form/CheckList.t | 5 +++++ 3 files changed, 41 insertions(+) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 4d9937f3f..54dffe3b2 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -37,6 +37,7 @@ - fixed: Hover Help outdated: automatically request commit - fixed: Thingy: Subtext disappears when editing a field - fixed: WebGUI Search errors - boolean search using filtering does not work + - fixed: Layout can now uncheck all Assets that are hidden. This also resolves any CheckList issue so that all buttons can be left blank. 7.5.18 - fixed: Collateral Image Manager broken in Firefox 3 diff --git a/lib/WebGUI/Form/CheckList.pm b/lib/WebGUI/Form/CheckList.pm index 62ba6001f..f3ab5ff5c 100644 --- a/lib/WebGUI/Form/CheckList.pm +++ b/lib/WebGUI/Form/CheckList.pm @@ -86,6 +86,41 @@ sub getName { return WebGUI::International->new($session, 'WebGUI')->get('941'); } +#------------------------------------------------------------------- + +=head2 getValue ( [ value ] ) + +Returns an array or a carriage return ("\n") separated scalar depending upon whether you're returning the values into an array or a scalar. Also parses the input values (wherever they come from) to see if it's a scalar then it splits on \n. + +=head3 value + +Optional values to process, instead of POST input. + +=cut + +sub getValue { + my ($self, $value) = @_; + my @values = (); + if (defined $value) { + if (ref $value eq "ARRAY") { + @values = @{$value}; + } + else { + $value =~ s/\r//g; + @values = split "\n", $value; + } + } + if (scalar @values < 1 && $self->session->request) { + my $value = $self->session->form->param($self->get("name")); + if (defined $value) { + @values = $self->session->form->param($self->get("name")); + } + } + return wantarray ? @values : join("\n",@values); +} + + + #------------------------------------------------------------------- =head2 getSelectAllButton ( ) diff --git a/t/Form/CheckList.t b/t/Form/CheckList.t index f2b32dde9..1838b7802 100644 --- a/t/Form/CheckList.t +++ b/t/Form/CheckList.t @@ -99,3 +99,8 @@ is( $inputs[0]->{value}, WebGUI::International->new($session,"Form_CheckList")->get("selectAll label"), 'The value is internationalized' ); + +my $checkl1 = WebGUI::Form::CheckList->new($session, {'defaultValue' => 1}); +is($checkl1->getValue(10), 10, "Get simple passed in value"); +is($checkl1->getValue(), '', "Get empty value in value"); +is($checkl1->get('defaultValue'), 1, "Check default value property");