X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Felements%2Fselect-table.html;h=a52fdfaaa505692ac8a0b5ffd22668eafeca0d59;hp=4b6ddb40ea7b2ad98ca2f3ff7f13f18a34f56c17;hb=d2b55d07a9e6e64a38877136d7974ab93e14f1ed;hpb=5d089cbe4980f7c9c25b83e164099b22bc59eead diff --git a/httemplate/elements/select-table.html b/httemplate/elements/select-table.html index 4b6ddb40e..a52fdfaaa 100644 --- a/httemplate/elements/select-table.html +++ b/httemplate/elements/select-table.html @@ -159,7 +159,7 @@ my $key = $opt{'value_col'} || $dbdef_table->primary_key; my $name_col = $opt{'name_col'}; -my $value = $opt{'curr_value'} || $opt{'value'}; +my $value = exists($opt{'curr_value'}) ? $opt{'curr_value'} : $opt{'value'}; $value = [ split(/\s*,\s*/, $value) ] if $opt{'multiple'} && $value =~ /,/; #my $addl_from = $opt{'addl_from'} || ''; @@ -182,6 +182,7 @@ if ( $opt{'records'} ) { unless $opt{'presorted'}; } else { @records = qsearch( { + 'select' => $opt{'select'} || '*', 'table' => $opt{'table'}, 'addl_from' => $opt{'addl_from'}, 'hashref' => $hashref, @@ -194,13 +195,22 @@ if ( ref( $value ) eq 'ARRAY' ) { $value = { map { $_ => 1 } @$value }; } -unless ( !ref($value) && $value < 1 # !$value #ignore negatives too - or ! exists( $opt{hashref}->{disabled} ) #?? - #or grep { $value == $_->$key() } @records - ) { + +if ( + (ref $value && $value) + or (ref $opt{hashref} && exists $opt{hashref}->{disabled}) + or $opt{also_show_option} +) { + delete $opt{hashref}->{disabled}; - foreach my $v ( ref($value) ? keys %$value : ($value) ) { + # also_show_option: (hack for change_pkg form): + # Include an absent select option, without selecting it + # as the curr_value + my @also_show = ref($value) ? keys %$value : ($value); + push @also_show, $opt{also_show_option} if $opt{also_show_option}; + + foreach my $v ( @also_show ) { next if grep { $v == $_->$key() } @records; $opt{hashref}->{$key} = $v;