fixing combo/select boxes on Matrix search and edit listing screens

This commit is contained in:
Yung Han Khoe 2009-02-27 14:17:09 +00:00
parent 2cabca66e9
commit 45a724f761
2 changed files with 17 additions and 4 deletions

View file

@ -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});
}
}

View file

@ -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);