Maypole::Model:CDBI::FromCGI - Validate form input and populate Model objects |
Maypole::Model:CDBI::FromCGI - Validate form input and populate Model objects
$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);
Provides a way to validate form input and populate Model Objects, based on Class::DBI::FromCGI.
Replicates Class::DBI::FromCGI method of same name :
__PACKAGE__->untaint_columns( printable => [qw/Title Director/], integer => [qw/DomesticGross NumExplodingSheep], date => [qw/OpeningDate/], );
gets the untaint type for a column as set in "untaint_types"
Returns errors that ocurred during an operation.
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)
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.
$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.
Validates (untaints) a hash of possibly mixed table data. Returns validated and errors ($validated, $errors). If no errors then undef in that spot.
$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.
Maypole Developers
Peter Speltz, Aaron Trevena
Tony Bowden
* Tests * add_to_from_cgi, search_from_cgi * complete documentation * ensure full backward compatibility with Class::DBI::FromCGI
Please direct all correspondence regarding this module to: Maypole list.
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.
the Class::DBI manpage, the Class::DBI::FromCGI manpage
Maypole::Model:CDBI::FromCGI - Validate form input and populate Model objects |