add usage classes to rate details
[freeside.git] / httemplate / edit / elements / edit.html
index 4a62ba3..3896f17 100644 (file)
@@ -3,8 +3,12 @@
 Example:
 
   include( 'elements/edit.html',  
-    'name'  =>
-    'table' =>
+    'name_singular' =>  #singular name for the record
+                        # (preferred, will be pluralized automatically)
+    'name'          =>  #name for the record
+                        # (deprecated, will be pluralized simplistically)
+    'table'         =>
+
     #? 'primary_key' => #required when the dbdef doesn't know...???
     'labels' => {
                   'column' => 'Label',
@@ -91,7 +95,7 @@ Example:
     'agent_null_right' => 'Access Right Name',
    
     #run when re-displaying with an error
-    'error_callback' => sub { my( $cgi, $object, $fields_listref ) = @_; },
+    'error_callback' => sub { my( $cgi, $object, $fields_listref, $opt_hashref ) = @_; },
    
     #run when editing
     'edit_callback' => sub { my( $cgi, $object, $fields_listref ) = @_; },
@@ -106,10 +110,10 @@ Example:
     'new_callback' => sub { my( $cgi, $object, $fields_listref ) = @_; },
    
     #run before display to return a different value
-    'value_callback' => sub { my( $columname, $value ) = @_; },
+    'value_callback' => sub { my( $columname, $value ) = @_; },
 
-    #XXX describe
-    'field_callback' => sub { },
+    #run before display to manipulate element of the 'fields' arrayref
+    'field_callback' => sub { my( $cgi, $object, $field_hashref ) = @_; },
 
     'viewall_dir' => '', #'search' or 'browse', defaults to 'search'
 
@@ -179,7 +183,7 @@ Example:
 %                       @$fields
 %                 ) {
 %
-%   &{ $opt{'field_callback'} }( $f )
+%   my $trash = &{ $opt{'field_callback'} }( $cgi, $object, $f )
 %     if $opt{'field_callback'};
 %
 %   my $field = $f->{'field'};
@@ -212,6 +216,7 @@ Example:
 %     #select(-*)
 %     'options'       => $f->{'options'},
 %     'labels'        => $f->{'labels'},
+%     'empty_label'   => $f->{'empty_label'},
 %     'multiple'      => $f->{'multiple'},
 %     'disable_empty' => $f->{'disable_empty'},
 %     #select-reason
@@ -226,10 +231,18 @@ Example:
 %     'disabled'      => $f->{'disabled'},
 %   );
 %
-%   #select-table
+%   #select-table, checkboxes-table
 %   $include_common{$_} = $f->{$_}
 %     foreach grep exists($f->{$_}), qw( table name_col );
 %
+%   #checkboxes-table
+%   $include_common{$_} = $f->{$_}
+%     foreach grep exists($f->{$_}), qw( target_table link_table );
+%
+%   #*-table
+%   $include_common{$_} = $f->{$_}
+%     foreach grep exists($f->{$_}), qw( hashref agent_virt agent_null_right );
+%
 %   if ( $type eq 'tablebreak-tr-title' ) {
 %     $include_common{'table_id'} = 'TableNumber'. $tablenum++
 %   }
@@ -548,7 +561,7 @@ if ( $cgi->param('error') ) {
     map { $_ => scalar($cgi->param($_)) } fields($table)
   });
 
-  &{$opt{'error_callback'}}($cgi, $object, $fields)
+  &{$opt{'error_callback'}}($cgi, $object, $fields, \%opt )
     if $opt{'error_callback'};
 
 } elsif ( $cgi->keywords || $cgi->param($pkey) ) { #editing
@@ -607,9 +620,9 @@ my @menubar = ();
 if ( $opt{'menubar'} ) {
   @menubar = @{ $opt{'menubar'} };
 } else {
+  my $items = $opt{'name'} ? $opt{'name'}.'s' : PL($opt{'name_singular'});
   @menubar = (
-    #eventually use Lingua::bs to pluralize
-    "View all $opt{'name'}s" => $viewall_url,
+    "View all $items" => $viewall_url,
   );
 }