Site::SQLForm - HTML forms bound to SQL tables
use Site::SQLForm;
$f = Site::SQLForm -> new(); $f -> dbh( $dbh );
$f -> table( 'test' ); $f -> addfields( { ... } );
if( $f -> handle() ) { print "Record handled!"; }
$f -> display();
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.
This handles any incoming requests, add, edit or delete.
This actually displays the form code
Enables and disables adding, editing, and deleting records from the database. Default is '1' for all of them.
The text on the front of the buttons.
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.
After a succesful handle()
call, this will be either ``ADD'',
``EDIT'', or ``DELETE'' telling what the form actually did.
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.
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.
(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.
This contains all the addcarries, any hidden stuff needed, and the form declaration. This is required.
Error messages for the form will be here. If you don't include it, errors will not be displayed to the browser!
Under the byname variable are all fields by name, with each field having a :label, :field, and :display for the display value.
Same as byname except by bound to fields.
A loop[] variable, and for each item has a label, field and display similar to the byname variable.
These are the add/edit/delete BUTTONS. Include or exclude them as you wish.
This is required and closes up the form.
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.
perl(1).