X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Felements%2Fedit.html;h=1d472099b0dbdc34572388e722f906ffe53fb143;hb=8fe6c833babe44bb707b8c47273b04fe39edfbaf;hp=4d5beee71a1aa631791f5f132bf11e8c2491a643;hpb=aeb90ade381fc3d5477db0334048c2af623fccfe;p=freeside.git diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html index 4d5beee71..1d472099b 100644 --- a/httemplate/edit/elements/edit.html +++ b/httemplate/edit/elements/edit.html @@ -7,7 +7,7 @@ Example: # (preferred, will be pluralized automatically) 'name' => #name for the record # (deprecated, will be pluralized simplistically) - 'table' => + 'table' => #database table #? 'primary_key' => #required when the dbdef doesn't know...??? 'labels' => { @@ -114,10 +114,15 @@ Example: #we're in a popup (no title/menu/searchboxes) 'popup' => 1, + #if you need to access the submit button + 'submit_id' => 'mysubmitbuttonid', + #we're embedded (rows only: no header at all, no html_init, no error # display, no
, no hidden fields for table name or primary key, no # display of primary key, no submit button, no html_foot, no footer) 'embed' => $object, #need to pass the object + 'tablenum' => 4, #need to specify a table number when using multiple + #embedded edits on a page (and m2 stuff) #don't show the primary key label and value 'no_pkey_display' => 1, @@ -130,6 +135,11 @@ Example: 'html_init' => '', #after the header/menubar + 'form_init' => '', #after html_init, error and the opening , but + #before any other form contents + + 'html_table_class' => '', #HTML 'html_table_bottom' => '', @@ -233,6 +243,7 @@ Example: % my $url = $opt{'post_url'} || popurl(1)."process/$table.html"; +% $js_form_validate = { 'edit_topform' => { 'name' => 'edit_topform' } }; - + + + <% defined($opt{'form_init'}) + ? ( ref($opt{'form_init'}) + ? &{$opt{'form_init'}}() + : $opt{'form_init'} + ) + : '' + %> % unless ( $opt{'no_pkey_display'} ) { @@ -256,8 +275,12 @@ Example: % } -% my $tablenum = 0; -
+% my $tablenum = $opt{'tablenum'} || 0; +
+> % my $g_row = 0; % my @g_row_stack = (); @@ -338,21 +361,23 @@ Example: % #contact % 'custnum' => $f->{'custnum'}, % 'prospectnum' => $f->{'prospectnum'}, +% % ); % % $include_common{$_} = $f->{$_} foreach grep exists($f->{$_}), % qw( js_only html_only select_only layers_only cell_style ),#selectlayers,? % qw( empty_label ), # select-* -% qw( value_col compare_sub order_by ), # select-table +% qw( value_col compare_sub order_by addl_from ), # select-table % qw( table name_col ), #(select,checkboxes)-table % qw( target_table link_table ), #checkboxes-table % qw( hashref agent_virt agent_null agent_null_right ),#*-table % qw( formatted_value ), #fixed % qw( country ), #select-country % qw( width height config ), #htmlarea -% qw( alt_format ), #select-cust_location +% qw( is_optional alt_format ), #select-cust_location % qw( classnum ), # select-inventory_item % qw( aligned ), # columnstart +% qw( debug ), # select-table % ; % % #select-table @@ -376,6 +401,8 @@ Example: % % my $layer_prefix_on = ''; % +% my $submitid = $opt{submit_id} ? $opt{submit_id} : ''; +% % my $include_sub = sub { % my %opt = @_; % @@ -388,11 +415,19 @@ Example: % $include_common{'layer_prefix'} = "$field$fieldnum." % if $layer_prefix_on; % +% ## set conditionname field values for validation. +% if ($field eq 'conditionname') { +% my $validate_field = $field . $fieldnum . '.after_event.run_delay'; +% $js_form_validate->{edit_topform}->{validate_fields}{$validate_field} = 'digits: true'; +% $js_form_validate->{edit_topform}->{error_message}{$validate_field} = 'Please only enter numbers here.'; +% } +% % my @include = % ( "/elements/$include.html", % 'field' => "$field$fieldnum", % 'id' => "$field$fieldnum", #separate? % 'label_id' => $field."_label$fieldnum", #don't want field0_label0... +% 'submit_id' => $submitid, % %include_common, % %opt, % ); @@ -405,6 +440,7 @@ Example: % 'value' => $opt{curr_value}, % 'label' => $label, % 'noinit' => $f->{noinit}, +% 'required' => $f->{'required'}, % } % ); % } @@ -611,6 +647,15 @@ Example: return; } +% if ( exists( $f->{'js_spawn_test'} ) ) { + // XXX check a passed-in hook here and optionall return + if ( <% $f->{'js_spawn_test'} %> ) { + // then go ahead and spawn + } else { + return; + } +% } + // change the label on the last entry & add a remove button var prev_label = document.getElementById('<% $field %>_label' + <%$field%>_fieldnum ); prev_label.innerHTML = ' <% $f->{'m2_label'} || $field %>'; @@ -630,7 +675,7 @@ Example: var newrow = <% include(@layer_opt, html_only=>1) |js_string %>; % #until the rest have html/js_only -% if ( $type eq 'selectlayers' || $type =~ /^select-cgp_rule_/ ) { +% if ( ($type eq 'selectlayers') || ($type eq 'selectlayersx') || ($type =~ /^select-cgp_rule_/) || ($type eq 'contact') ) { var newfunc = <% include(@layer_opt, js_only=>1) |js_string %>; % } else { var newfunc = ''; @@ -813,7 +858,11 @@ Example: : $opt{'html_foot'} %> - <% include("/elements/footer.html") %> +% my %footerdata = ( +% 'formvalidation' => $js_form_validate, +% ); + + <% include("/elements/footer.html", %footerdata) %> % } <%init> @@ -829,7 +878,11 @@ my $pkey = dbdef->table($table)->primary_key; #? $opt{'primary_key'} || my $fields = $opt{'fields'} #|| [ grep { $_ ne $pkey } dbdef->table($table)->columns ]; || [ grep { $_ ne $pkey } fields($table) ]; -#my @actualfields = map { ref($_) ? $_->{'field'} : $_ } @$fields; +my @actualfields = map { ref($_) ? $_->{'field'} : $_ } @$fields; + +push @actualfields, $pkey; + +my $js_form_validate = {}; my( $mode, $object); my $clone = ''; @@ -870,7 +923,7 @@ if ( $opt{'embed'} ) { $mode = 'error'; $object = $class->new( { - map { $_ => scalar($cgi->param($_)) } fields($table) + map { $_ => scalar($cgi->param($_)) } @actualfields }); &{$opt{'error_callback'}}( $cgi, $object, $fields, \%opt )