NAME
Maypole::Model:CDBI::FromCGI - Validate form input and populate Model objects
SYNOPSIS
$obj = $class->create_from_cgi($r);
$obj = $class->create_from_cgi($r, { params => {data1=>...}, required => [..],
ignore => [...], all => [...]);
$obj = $class->create_from_cgi($h, $options); # CDBI::FromCGI style, see docs
$obj->update_from_cgi($r);
$obj->update_from_cgi($h, $options);
$obj = $obj->add_to_from_cgi($r);
$obj = $obj->add_to_from_cgi($r, { params => {...} } );
# This does not work like in CDBI::FromCGI and probably never will :
# $class->update_from_cgi($h, @columns);
DESCRIPTION
Provides a way to validate form input and populate Model Objects, based on Class::DBI::FromCGI.
METHODS
untaint_columns
Replicates Class::DBI::FromCGI method of same name :
__PACKAGE__->untaint_columns(
printable => [qw/Title Director/],
integer => [qw/DomesticGross NumExplodingSheep],
date => [qw/OpeningDate/],
);
untaint_type
gets the untaint type for a column as set in "untaint_types"
cgi_update_errors
Returns errors that ocurred during an operation.
create_from_cgi
Based on the same method in Class::DBI::FromCGI.
Creates multiple objects from a cgi form. Errors are returned in cgi_update_errors
It can be called Maypole style passing the Maypole request object as the first arg, or Class::DBI::FromCGI style passing the Untaint Handler ($h) as the first arg.
A hashref of options can be passed as the second argument. Unlike in the CDBI equivalent, you can *not* pass a list as the second argument. Options can be : params -- hashref of cgi data to use instead of $r->params, required -- list of fields that are required ignore -- list of fields to ignore all -- list of all fields (defaults to $class->columns)
update_from_cgi
Replicates the Class::DBI::FromCGI method of same name. It updates an object and returns 1 upon success. It can take the same arguments as create_form_cgi. If errors, it sets the cgi_update_errors.
add_to_from_cgi
$obj->add_to_from_cgi($r[, $opts]);
Like add_to_* for has_many relationships but will add nay objects it can figure out from the data. It returns a list of objects it creates or nothing on error. Call cgi_update_errors with the calling object to get errors. Fatal errors are in the respective "FATAL" key.
validate_all
Validates (untaints) a hash of possibly mixed table data. Returns validated and errors ($validated, $errors). If no errors then undef in that spot.
validate_inputs
$self->validate_inputs($h, $opts);
This is the main validation method to validate inputs for a single class. Most of the time you use validate_all.
Returns validated and errors.
If no errors then undef in that slot.
Note: This method is currently experimental (in 2.11) and may be subject to change without notice.
classify_form_inputs
$self->classify_form_inputs($params[, $delimiter]);
Foreign inputs are inputs that have data for a related table. They come named so we can tell which related class they belong to. This assumes the form : $accessor . $delimeter . $column recursively classifies them into hashes. It returns a hashref.
MAINTAINER
Maypole Developers
AUTHORS
Peter Speltz, Aaron Trevena
AUTHORS EMERITUS
Tony Bowden
TODO
* Tests * add_to_from_cgi, search_from_cgi * complete documentation * ensure full backward compatibility with Class::DBI::FromCGI
BUGS and QUERIES
Please direct all correspondence regarding this module to: Maypole list.
COPYRIGHT AND LICENSE
Copyright 2003-2004 by Peter Speltz
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.