From 45a724f7618a1313e552341188ccf63dc29a8cd3 Mon Sep 17 00:00:00 2001 From: Yung Han Khoe Date: Fri, 27 Feb 2009 14:17:09 +0000 Subject: [PATCH] fixing combo/select boxes on Matrix search and edit listing screens --- lib/WebGUI/Asset/MatrixListing.pm | 8 ++++++++ lib/WebGUI/Asset/Wobject/Matrix.pm | 13 +++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/lib/WebGUI/Asset/MatrixListing.pm b/lib/WebGUI/Asset/MatrixListing.pm index 61ed40a2e..b5e138ee4 100644 --- a/lib/WebGUI/Asset/MatrixListing.pm +++ b/lib/WebGUI/Asset/MatrixListing.pm @@ -313,6 +313,14 @@ sub getEditForm { $attribute->{label} = $attribute->{name}; $attribute->{subtext} = $attribute->{description}; $attribute->{name} = 'attribute_'.$attribute->{attributeId}; + if($attribute->{fieldType} eq 'Combo'){ + my %options; + tie %options, 'Tie::IxHash'; + %options = $db->buildHash("select value, value from MatrixListing_attribute + where attributeId = ? and value != '' order by value",[$attribute->{attributeId}]); + $attribute->{options} = \%options; + $attribute->{extras} = "style='width:120px'"; + } $form->dynamicField(%{$attribute}); } } diff --git a/lib/WebGUI/Asset/Wobject/Matrix.pm b/lib/WebGUI/Asset/Wobject/Matrix.pm index 5b65f3aa3..b9a09fc0c 100644 --- a/lib/WebGUI/Asset/Wobject/Matrix.pm +++ b/lib/WebGUI/Asset/Wobject/Matrix.pm @@ -1144,6 +1144,7 @@ sub www_search { my $self = shift; my $var = $self->get; + my $db = $self->session->db; $var->{compareForm} = $self->getCompareForm; $self->session->style->setScript($self->session->url->extras('yui/build/yahoo/yahoo-min.js'), @@ -1175,7 +1176,7 @@ sub www_search { my $attributes; my @attribute_loop; my $categoryLoopName = $self->session->url->urlize($category)."_loop"; - $attributes = $self->session->db->read("select * from Matrix_attribute where category =? and assetId = ?", + $attributes = $db->read("select * from Matrix_attribute where category =? and assetId = ?", [$category,$self->getId]); while (my $attribute = $attributes->hashRef) { $attribute->{label} = $attribute->{name}; @@ -1184,10 +1185,14 @@ sub www_search { $attribute->{extras} = " class='attributeSelect'"; if($attribute->{fieldType} eq 'Combo'){ $attribute->{fieldType} = 'SelectBox'; - } - if($attribute->{fieldType} eq 'SelectBox'){ - $attribute->{options} = "blank\n".$attribute->{options}; + my %options; + tie %options, 'Tie::IxHash'; + %options = $db->buildHash('select value, value from MatrixListing_attribute + where attributeId = ? order by value',[$attribute->{attributeId}]); + $options{'blank'} = 'blank'; + $attribute->{options} = \%options; $attribute->{value} = 'blank'; + $attribute->{extras} = "style='width:120px'"; } $attribute->{form} = WebGUI::Form::DynamicField->new($self->session,%{$attribute})->toHtml; push(@attribute_loop,$attribute);