RT# 83450 - fixed rateplan export
[freeside.git] / FS / FS / part_virtual_field.pm
index 0011ec6..eae519f 100755 (executable)
@@ -2,7 +2,7 @@ package FS::part_virtual_field;
 use base qw(FS::Record);
 
 use strict;
-use CGI qw(escapeHTML);
+use HTML::Entities;
 use FS::Schema qw( dbdef );
 
 =head1 NAME
@@ -59,6 +59,7 @@ Create a new record.  To add the record to the database, see "insert".
 
 sub table { 'part_virtual_field'; }
 sub virtual_fields { () }
+sub virtual_fields_hash { () }
 
 =item widget UI_TYPE MODE [ VALUE ]
 
@@ -81,20 +82,21 @@ VALUE (optional) is the current value of the field.
 
 sub widget {
   my $self = shift;
-  my ($ui_type, $mode, $value) = @_;
+  my ($ui_type, $mode, $value, $header_col_type) = @_;
+  $header_col_type = 'TD' unless $header_col_type;
   my $text;
   my $label = $self->label || $self->name;
 
   if ($ui_type eq 'HTML') {
     if ($mode eq 'view') {
-      $text = q!<TR><TD ALIGN="right">! . $label . 
-              q!</TD><TD BGCOLOR="#ffffff">! . $value .
+      $text = q!<TR><!.$header_col_type.q! ALIGN="right">! . encode_entities($label) .
+              q!</!.$header_col_type.q!><TD BGCOLOR="#ffffff">! . encode_entities($value) .
               q!</TD></TR>! . "\n";
     } elsif ($mode eq 'edit') {
-      $text = q!<TR><TD ALIGN="right">! . $label .
-              q!</TD><TD>!;
-        $text .= q!<INPUT NAME="! . $self->name .
-                q!" VALUE="! . escapeHTML($value) . q!"!;
+      $text = q!<TR><!.$header_col_type.q! ALIGN="right">! . encode_entities($label) .
+              q!</!.$header_col_type.q!><TD>!;
+        $text .= q!<INPUT TYPE=text NAME="! . $self->name .
+                q!" VALUE="! . encode_entities($value) . q!"!;
         if ($self->length) {
           $text .= q! SIZE="! . $self->length . q!"!;
         }