NAME

Site::SQLForm - HTML forms bound to SQL tables


SYNOPSIS

  use Site::SQLForm;

  $f = Site::SQLForm -> new();
  $f -> dbh( $dbh );

  $f -> table( 'test' );
  $f -> addfields( { ... } );

  if( $f -> handle() )
  {
    print "Record handled!";
  }

  $f -> display();


DESCRIPTION

SQLForm inherits all field handling methods from Site::SQLContainer. Read the pod for that modules for the basic information about how to get the class to actually ``do'' anything.


handle

This handles any incoming requests, add, edit or delete.


display

This actually displays the form code


allow(add/edit/delete)

Enables and disables adding, editing, and deleting records from the database. Default is '1' for all of them.


(add/edit/delete/deleteno/deleteyes)button

The text on the front of the buttons.


transaction_support

If set to a filename, it will eliminate duplicate transactions by assigning a txid to each transaction and only performing it once. Uses the DB_File to keep track of txid's.


lastaction

After a succesful handle() call, this will be either ``ADD'', ``EDIT'', or ``DELETE'' telling what the form actually did.


deletetemplate

Template for deleting a record, for a custom delete form. Adds a 'yes' and 'no' variable for the t:var thing for the yes and no buttons.


badform

You can check some form values and set this to '1' if things aren't right. It will force the values back in to the fields and make the user submit them again, hopefully after changing them.


Templates

(if you just want quick templates, see the DUMP_TEMPLATE method)

You can use templates to customize the look of forms. The default look is to have labels down the left with fields on the right in a table, like:

 label: field
 label: field
 ...

If you wanted though, you could change it to be:

 label: field
 label: field field field
        label: field <submit>

Or anything else using templates.

The default template looks like this:

<t:var name=begin/> <t:var name=message/> <TABLE BORDER=0> <t:loop name=fields> <TR> <TD><t:iftrue name=label><B><t:var name=label/>:</B></t:iftrue></TD> <TD><t:var name=field/></TD> </TR> </t:loop> </TABLE> <t:var name=add/> <t:var name=edit/> <t:var name=delete/> <t:var name=end/>

You can reference the fields in the fields[] loop one by one in the added() order, or you can do things byname/boundto (which is more likely for custom forms) like this:

<t:var name=begin/> <t:var name=message/>

<t:with name=byname> <t:var name=name:label/>: <t:var name=name:field/> </t:with>

<t:var name=add/> <t:var name=edit/> <t:var name=delete/> <t:var name=end/>

There are several values defined for use, with begin/end being required.


var begin

This contains all the addcarries, any hidden stuff needed, and the form declaration. This is required.


var message

Error messages for the form will be here. If you don't include it, errors will not be displayed to the browser!


var byname

Under the byname variable are all fields by name, with each field having a :label, :field, and :display for the display value.


var byboundto

Same as byname except by bound to fields.


var fields

A loop[] variable, and for each item has a label, field and display similar to the byname variable.


var add/edit/delete

These are the add/edit/delete BUTTONS. Include or exclude them as you wish.


var end

This is required and closes up the form.


AUTHOR

Copyright (c) 2001 Steve Slaven <bpk@hoopajoo.net> All rights reserved.

This program is free software and is provided ``as is'' without express or implied warranty. You can redistribute it and/or modify it under the same terms as Perl itself.


SEE ALSO

perl(1).