X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=httemplate%2Fedit%2Felements%2Fedit.html;h=4935ddc1ae40992fee64914f7be63c99950ba2b8;hb=03ceab71dad1e5eb366865d304e5e459cc905ce4;hp=1a567a12e11ef22c702f2da8303d391ce240af8c;hpb=2a6aa24137ddd389c1e644f5ece325c5b5dbaf3a;p=freeside.git diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html index 1a567a12e..4935ddc1a 100644 --- a/httemplate/edit/elements/edit.html +++ b/httemplate/edit/elements/edit.html @@ -3,54 +3,67 @@ 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', } - listref - each item is a literal column name (or method) or hashref - or (notyet) coderef - if not specified all columns (except for the primary key) will be editable + #listref - each item is a literal column name (or method) or hashref + # or (notyet) coderef + #if not specified all columns (except for the primary key) will be editable 'fields' => [ 'columname', { 'field' => 'another_columname', 'type' => 'text', #text + #password #money + #percentage #checkbox #select - #selectlayers + #selectlayers (can now use after a tablebreak-tr-title... but not inside columnstart/columnnext/columnend) #title + #tablebreak-tr-title + #columnstart + #columnnext + #columnend #hidden - hidden value from object - #fixed - display fixed value from here - #fixedhidden - hidden value from here - 'value' => 'Y', #for checkbox, title, fixed, fixedhidden + #fixed - display fixed value from object or here + #fixed-country + #fixed-state + 'value' => 'Y', #for checkbox, title, fixed, hidden 'disabled' => 0, 'onchange' => 'javascript_function', - 'm2name_table' => 'table_name', #only tested w/ - # selectlayers so far - # might work w/select - # dunno others - 'm2name_namecol' => 'name_column', # - 'm2name_label' => 'Label', # - 'm2name_new_default' => \@table_name_objects, #default - #m2name - #objects for - #new records - 'm2name_error_callback' => sub { my($cgi, $object) = @_; }, - 'm2name_remove_warnings' => \%warnings, #hashref of warning - #messages for - #m2name removal - 'm2name_new_js' => 'function_name', #javascript function - #called on spawned rows - #(one arg: new_element) - 'm2name_remove_js' => 'function_name', #js function called - #when a row is - #deleted - #(three args: - # value, text, - # 'no_match') + + #m2 stuff only tested w/selectlayers so far + #might work w/select too, dunno others + 'm2name_table' => 'table_name', + 'm2name_namecol' => 'name_column', + #OR# + 'm2m_method' => + #'m2m_srccol' => #opt, if not the same as this table + 'm2m_dstcol' => #required for now, eventuaully opt, if not the same as target table + + 'm2_label' => 'Label', # + 'm2_new_default' => \@table_name_objects, #default + #m2 objects for + #new records + 'm2_error_callback' => sub { my($cgi, $object) = @_; }, + 'm2_remove_warnings' => \%warnings, #hashref of warning + #messages for m2 + #removal + 'm2_new_js' => 'function_name', #javascript function called + #on spawned rows (one arg: + #new_element) + 'm2_remove_js' => 'function_name', #js function called when + #a row is deleted (three + #args: value, text, + #'no_match') #layer_fields & layer_values_callback only for selectlayer 'layer_fields' => [ 'fieldname' => 'Label', @@ -78,47 +91,108 @@ Example: 'menubar' => '', #menubar arrayref #agent virtualization - 'agent_virt' => 1, - 'agent_null_right' => 'Access Right Name', - - #run when re-displaying with an error - 'error_callback' => sub { my( $cgi, $object, $fields_listref ) = @_; }, - - #run when editing - 'edit_callback' => sub { my( $cgi, $object, $fields_listref ) = @_; }, - - # returns a hashref for the new object - 'new_hashref_callback' - - #run when adding - 'new_callback' => sub { my( $cgi, $object, $fields_listref ) = @_; }, - - #XXX describe - 'field_callback' => sub { }, - + 'agent_virt' => 1, + 'agent_null_right' => 'Access Right Name', + 'agent_clone_extra_sql' => '', #if provided, this overrides the extra_sql + #implementing agent virt, for clone + #operations. i.e. pass "1=1" to allow + #cloning anything + + 'viewall_dir' => '', #'search' or 'browse', defaults to 'search' + + # overrides default popurl(1)."process/$table.html" + 'post_url' => popurl(1).'process/something', + + #we're in a popup (no title/menu/searchboxes) + 'popup' => 1, + + ### + # HTML callbacks + ### + + 'body_etc' => '', # Additional BODY attributes, i.e. onLoad="" + + 'html_init' => '', #after the header/menubar + #string or coderef of additional HTML to add before 'html_table_bottom' => '', - - 'viewall_dir' => '', #'search' or 'browse', defaults to 'search' - + + #after but before the submit 'html_bottom' => '', #string 'html_bottom' => sub { my $object = shift; # ... "html_string"; }, + + #at the very bottom (well, as low as you can go from here) + 'html_foot' => '', + + ### + # initialization callbacks + ### + + ###global callbacks, always run if provided + + #after decoding long CGI "redirect=" responses but + # before object creation/search + # (useful if you have a long form that might trigger redirect= and you need + # to do things with $cgi params - they're not decoded in the calling + # <%init> block yet) + 'begin_callback' = sub { my( $cgi, $fields_listref, $opt_hashref ) = @_; }, + + #after the mode-specific object creation/search + 'end_callback' = sub { my( $cgi, $object, $fields_listref, $opt_hashref ) = @_; }, + + ###mode-specific callbacks. one (and only one) of these four is called - # overrides default popurl(1)."process/$table.html" - 'post_url' => popurl(1).'process/something', + #run when adding + 'new_callback' => sub { my( $cgi, $object, $fields_listref, $opt_hashref ) = @_; }, + + #run when editing + 'edit_callback' => sub { my( $cgi, $object, $fields_listref, $opt_hashref ) = @_; }, + + #run when re-displaying with an error + 'error_callback' => sub { my( $cgi, $object, $fields_listref, $opt_hashref ) = @_; }, + + #run when cloning + 'clone_callback' => sub { my( $cgi, $object, $fields_listref, $opt_hashref ) = @_; }, + + ###callbacks called in new mode only + + # returns a hashref for the new object + 'new_hashref_callback' + + # returns the new object iself (otherwise, ->new is called) + 'new_object_callback' + + ###display callbacks + + #run before display to return a different value + 'value_callback' => sub { my( $columname, $value ) = @_; }, + + #run before display to manipulate element of the 'fields' arrayref + 'field_callback' => sub { my( $cgi, $object, $field_hashref ) = @_; }, + ); %doc> -<% include("/elements/header.html", $title, - include( '/elements/menubar.html', @menubar ) +<% include('/elements/header'. ( $opt{popup} ? '-popup' : '' ). '.html', + $title, + include( '/elements/menubar.html', @menubar ), + $opt{'body_etc'}, ) %> +<% defined($opt{'html_init'}) + ? ( ref($opt{'html_init'}) + ? &{$opt{'html_init'}}() + : $opt{'html_init'} + ) + : '' +%> + <% include('/elements/error.html') %> % my $url = $opt{'post_url'} || popurl(1)."process/$table.html"; @@ -126,23 +200,26 @@ Example: