selectable choice for arbitrary fields, RT#25623
[freeside.git] / httemplate / edit / elements / svc_Common.html
index 0955d49..58af6bc 100644 (file)
                      $f->{'extra_sql'}  .= ' OR svcnum = '. $object->svcnum
                        if $object->svcnum;
                      $f->{'extra_sql'}  .= ' ) ';
-                     $f->{'disable_empty'} = $object->svcnum ? 1 : 0,
+                     $f->{'disable_empty'} = $object->svcnum ? 1 : 0;
+                     if ( $f->{'field'} eq 'mac_addr' ) {
+                       $f->{'compare_sub'} = sub {
+                         my($a, $b) = @_;
+                         $a =~ s/[-: ]//g;
+                         $b =~ s/[-: ]//g;
+                         lc($a) eq lc($b);
+                       };
+                     }
                    } elsif ( $flag eq 'H' ) {
                      $f->{'type'}        = 'select-hardware_type';
                      $f->{'hashref'}     = {
                                             'classnum'=>$columndef->columnvalue
                                            };
-                     $f->{'empty_label'} = 'Select hardware type';
+                   } elsif ( $flag eq 'S' ) { #selectable choice
+                     $f->{type}    = 'select';
+                     $f->{options} = [ split( /\s*,\s*/,
+                                                $columndef->columnvalue)
+                                     ];
                    }
 
                    if (    $f->{'type'} eq 'select-svc_pbx'
                      $object->set('custnum', $cust_pkg->custnum);
                    }
 
+                   if ( my $cb = $opt{'svc_field_callback'} ) {
+                     &{ $cb }( $cgi, $object, $f);
+                   }
+
                  },
 
                  'html_init' => sub {