Site::SQLContainer - Base funcionality for forms/tables
use Site::SQLContainer; @ISA = qw( Site::SQLContainer );
The SQLContainer is a base class for SQLForm and SQLTable, providing general field and database handling code.
Creates a new object
This should be set with a valid DBI::DBD database handle, this would even work:
$f -> dbh( DBI -> connect( 'DBI:Pg:dbname=test' ) );
Though you might want to use a shared handle.
Sets the table name for this container. i.e. if you have a form based on a
table 'customers' you would set the table to 'customers' and use
addfield()
or addfields()
to place the fields in
the form.
Use this to add a field to a container. You need to specify the field type here and if it's bound/named or anything like that.
$f -> addfield( boundto => 'testid', type => 'text' );
The default type is text if omitted. For more information about fields and field types/options, see Site::SQLField.
Allows addition of multiple fields quickly. Takes a bunch of hashrefs.
$f -> addfields( { boundto => 'testid' }, { boundto => 'testvalue' }, { boundto => 'foreign_key', type => 'dropbox', rowsourcetype => 'query', rowsourcequery => 'select * from foreign_table' } );
Lots of times you'll have a screen based on a particular ID or some other
kind of data and it needs to be present in all queries. Use the
addcarry()
method to have these passed without fully qualified
names within the container, since normally fields are passed around by
tablename.pkey.fieldname. So if you need the customerid passed back when
the table re-sorts or the form submits or whatever, add a carry like this:
$f -> addcarry( customerid => $custid );
And it adds a HIDDEN field to whatever with NAME=customerid and VALUE= $custid.
These return the field named or bound to the argument. If you need to
change a default or if the field is enabled, etc. Most useful for things
created from a bind_sql_object()
call where you might need to
set defaults different from those within the class.
Creates a container from an SQL object. Sets the dbh(),
adds
the fields along with their fat{} (field attributes) and sets the pkeys,
etc.
Assigns a template object to the container. For more information about templates in general, see Site::Template. For more specific information about templates for tables or forms, see SQLForm and SQLTable.
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).