.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Class::DBI::AsForm 3pm" .TH Class::DBI::AsForm 3pm "2022-12-07" "perl v5.36.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Class::DBI::AsForm \- Produce HTML form elements for database columns .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 5 \& package Music::CD; \& use Class::DBI::AsForm; \& use base \*(AqClass::DBI\*(Aq; \& use CGI; \& ... \& \& sub create_or_edit { \& my $class = shift; \& my %cgi_field = $class\->to_cgi; \& return start_form, \& (map { "$_: ". $cgi_field{$_}\->as_HTML."
" } \& $class\->Columns), \& end_form; \& } \& \& #
\& # Title:
\& # Artist: \& # ... \& #
.Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module helps to generate \s-1HTML\s0 forms for creating new database rows or editing existing rows. It maps column names in a database table to \&\s-1HTML\s0 form elements which fit the schema. Large text fields are turned into textareas, and fields with a has-a relationship to other \&\f(CW\*(C`Class::DBI\*(C'\fR tables are turned into select drop-downs populated with objects from the joined class. .SH "METHODS" .IX Header "METHODS" The module is a mix-in which adds two additional methods to your \&\f(CW\*(C`Class::DBI\*(C'\fR\-derived class. .SS "to_cgi" .IX Subsection "to_cgi" This returns a hash mapping all the column names of the class to HTML::Element objects representing form widgets. .ie n .SS "to_field($field [, $how])" .el .SS "to_field($field [, \f(CW$how\fP])" .IX Subsection "to_field($field [, $how])" This maps an individual column to a form element. The \f(CW\*(C`how\*(C'\fR argument can be used to force the field type into one of \f(CW\*(C`textfield\*(C'\fR, \f(CW\*(C`textarea\*(C'\fR or \f(CW\*(C`select\*(C'\fR; you can use this is you want to avoid the automatic detection of has-a relationships. .SH "CHANGES" .IX Header "CHANGES" Version 1.x of this module returned raw \s-1HTML\s0 instead of \&\f(CW\*(C`HTML::Element\*(C'\fR objects, which made it harder to manipulate the \&\s-1HTML\s0 before sending it out. If you depend on the old behaviour, set \&\f(CW$Class::DBI::AsForm::OLD_STYLE\fR to a true value. .SH "MAINTAINER" .IX Header "MAINTAINER" Tony Bowden .SH "ORIGINAL AUTHOR" .IX Header "ORIGINAL AUTHOR" Simon Cozens .SH "BUGS and QUERIES" .IX Header "BUGS and QUERIES" Please direct all correspondence regarding this module to: bug\-Class\-DBI\-AsForm@rt.cpan.org .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" Copyright 2003\-2004 by Simon Cozens / Tony Bowden .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. .SH "SEE ALSO" .IX Header "SEE ALSO" Class::DBI, Class::DBI::FromCGI, HTML::Element.