RT# 79284 Updated discounts UI for Change Package screen
[freeside.git] / httemplate / elements / select-table.html
index d7ec015..a52fdfa 100644 (file)
@@ -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'} || '';
@@ -195,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;