Maypole...:FromCGI(3)

πŸ“¦
version 2.13 Β· 2 versions
, in fedora 43

🌸 Maypole...:FromCGI(3) 🌸

okay bestie, this page lives in the User Contributed Perl Documentation manual, and it's all about Maypole::Model:CDBI::FromCGI πŸ’– β€” the module that validates your form input and then populates your Model objects for you. it's giving "I'll handle the boring part, you go be the main character" ✨


✨ 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 πŸ’…

so the whole vibe here is: it gives you a way to validate form input and populate Model Objects, based on Class::DBI::FromCGI. that's the tea β˜• no cap.


πŸ‘‘ METHODS πŸ‘‘

🌈 untaint_columns 🌈

Replicates the Class::DBI::FromCGI method of the same name, fr fr:

__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. (yes, "ocurred", we keep it exactly as it is bestie πŸ’–) it's your receipts folder for what went wrong.

πŸ¦‹ 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 the 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. lowkey do not build your whole personality on it, it might shift 😭

πŸ“ 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, and 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 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. 🩷


πŸ‘€ SEE ALSO πŸ‘€

  • Class::DBI
  • Class::DBI::FromCGI

and that's the whole page bestie, you ate that πŸ’… this was Maypole...:FromCGI(3), generated from perl v5.42.0 on 2025-07-25, and you're officially a Unix girlie now. periodt. πŸ¦‹βœ¨

πŸ“¦ where this page comes from