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',
'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 ) = @_; },
'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'
% @$fields
% ) {
%
-% &{ $opt{'field_callback'} }( $f )
+% my $trash = &{ $opt{'field_callback'} }( $cgi, $object, $f )
% if $opt{'field_callback'};
%
% my $field = $f->{'field'};
% 'disabled' => $f->{'disabled'},
% );
%
-% #select-table
+% #selectlayers, others?
+% $include_common{$_} = $f->{$_}
+% foreach grep exists($f->{$_}),
+% qw( js_only html_only select_only layers_only cell_style);
+%
+% #select-*
+% $include_common{$_} = $f->{$_}
+% foreach grep exists($f->{$_}), qw( empty_label );
+%
+% #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++
% }
% 'object' => $object,
% 'cgi' => $cgi,
% 'onchange' => $onchange,
-% 'cell_style' => ( $fieldnum ? 'border-top:1px solid black' : '' ),
+% ( $fieldnum ? ('cell_style' => 'border-top:1px solid black') : () ),
% );
<% include( @include ) %>
<SCRIPT TYPE="text/javascript">
- var <%$field%>_rownum = <% $g_row %>;
+ var <%$field%>_rownum = <% $g_row - 1 %>;
var <%$field%>_fieldnum = <% $fieldnum %>;
function spawn_<%$field%>(what) {
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
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,
);
}