no need for a one-choice "Add new location" location dropdown on prospect add, RT...
[freeside.git] / httemplate / edit / elements / edit.html
index 8dd15dc..2f82f9c 100644 (file)
@@ -240,6 +240,7 @@ Example:
 
 % my $url = $opt{'post_url'} || popurl(1)."process/$table.html";
 
+% $js_form_validate = { 'edit_topform' => { 'name' => 'edit_topform' } };
   <FORM NAME   = "edit_topform"
         METHOD = POST
         ACTION = "<% $url %>"
@@ -247,7 +248,7 @@ Example:
   >
 
   <INPUT TYPE="hidden" NAME="svcdb" VALUE="<% $table %>">
-  <INPUT TYPE="hidden" NAME="<% $pkey %>" VALUE="<% $clone ? '' : $object->$pkey() %>">
+  <INPUT TYPE="hidden" ID="<% $pkey %>" NAME="<% $pkey %>" VALUE="<% $clone ? '' : $object->$pkey() %>">
 
   <% defined($opt{'form_init'}) 
         ? ( ref($opt{'form_init'})
@@ -357,6 +358,7 @@ Example:
 %     #contact
 %     'custnum'     => $f->{'custnum'},
 %     'prospectnum' => $f->{'prospectnum'},
+%
 %   );
 %
 %   $include_common{$_} = $f->{$_} foreach grep exists($f->{$_}),
@@ -369,9 +371,10 @@ Example:
 %     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
@@ -407,6 +410,13 @@ 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",
@@ -631,6 +641,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 = '<INPUT TYPE="button" VALUE="X" TITLE="Remove this <% lc($f->{'m2_label'}) %>" onClick="remove_<% $field %>(' + <%$field%>_fieldnum + ');" STYLE="color:#ff0000;font-weight:bold;padding-left:2px;padding-right:2px" >&nbsp;<% $f->{'m2_label'} || $field %>';
@@ -833,7 +852,11 @@ Example:
         : $opt{'html_foot'}
   %>
 
-  <% include("/elements/footer.html") %>
+% my %footerdata = (
+%   'formvalidation' => $js_form_validate,
+% );  
+
+  <% include("/elements/footer.html", %footerdata) %>  
 
 % }
 <%init>
@@ -851,6 +874,8 @@ my $fields = $opt{'fields'}
              || [ grep { $_ ne $pkey } fields($table) ];
 #my @actualfields = map { ref($_) ? $_->{'field'} : $_ } @$fields;
 
+my $js_form_validate = {};
+
 my( $mode, $object);
 my $clone = '';
 if ( $opt{'embed'} ) {