first part of ACL and re-skinning work and some other small stuff
[freeside.git] / httemplate / edit / elements / edit.html
index 5486b4b..120c03a 100644 (file)
   # 'menubar'     => '', #menubar arrayref
   #
   # 'viewall_dir' => '', #'search' or 'browse', defaults to 'search'
+  #
+  # 'html_bottom' => '', #string
+  # 'html_bottom' => sub {
+  #                        my $object = shift;
+  #                        # ...
+  #                        "html_string";
+  #                      },
 
   my(%opt) = @_;
 
@@ -27,6 +34,7 @@
   my $fields = $opt{'fields'}
                #|| [ grep { $_ ne $pkey } dbdef->table($table)->columns ];
                || [ grep { $_ ne $pkey } fields($table) ];
+  #my @actualfields = map { ref($_) ? $_->{'field'} : $_ } @$fields;
 
   my $object;
   if ( $cgi->param('error') ) {
     );
   }
 
-%>
-
-
-<%= include("/elements/header.html", $title,
+%><%= include("/elements/header.html", $title,
               include( '/elements/menubar.html', @menubar )
            )
 %>
 
 <%= ntable("#cccccc",2) %>
 
-<% foreach my $field ( @$fields ) { %>
+<% foreach my $f ( @$fields ) {
+
+    my( $field, $type);
+    if ( ref($f) ) {
+      $field = $f->{'field'},
+      $type  = $f->{'type'} || 'text',
+    } else {
+      $field = $f;
+      $type = 'text';
+    }
+
+%>
 
   <TR>
 
     </TD>
 
     <%
-      #just text in one size for now... eventually more options for
-      # uneditable, hidden, <SELECT>, etc. fields
+      #eventually more options for <SELECT>, etc. fields
     %>
 
     <TD>
-      <INPUT TYPE="text" NAME="<%= $field %>" VALUE="<%= $object->$field() %>">
+      <INPUT TYPE="<%= $type %>" NAME="<%= $field %>" VALUE="<%= $object->$field() %>">
     <TD>
 
   </TR>
 
 </TABLE>
 
+<%= ref( $opt{'html_bottom'} )
+      ? &{ $opt{'html_bottom'} }( $object )
+      : $opt{'html_bottom'}
+%>
+
 <BR>
 
 <INPUT TYPE="submit" VALUE="<%= $object->$pkey() ? "Apply changes" : "Add $opt{'name'}" %>">