Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

class::dbi::asform(3pm) [debian man page]

Class::DBI::AsForm(3pm) 				User Contributed Perl Documentation				   Class::DBI::AsForm(3pm)

NAME
Class::DBI::AsForm - Produce HTML form elements for database columns SYNOPSIS
package Music::CD; use Class::DBI::AsForm; use base 'Class::DBI'; use CGI; ... sub create_or_edit { my $class = shift; my %cgi_field = $class->to_cgi; return start_form, (map { "<b>$_</b>: ". $cgi_field{$_}->as_HTML." <br>" } $class->Columns), end_form; } # <form method="post"...> # Title: <input type="text" name="Title" /> <br> # Artist: <select name="Artist"> # <option value=1>Grateful Dead</option> # ... # </select> # ... # </form> DESCRIPTION
This module helps to generate HTML forms for creating new database rows or editing existing rows. It maps column names in a database table to HTML form elements which fit the schema. Large text fields are turned into textareas, and fields with a has-a relationship to other "Class::DBI" tables are turned into select drop-downs populated with objects from the joined class. METHODS
The module is a mix-in which adds two additional methods to your "Class::DBI"-derived class. to_cgi This returns a hash mapping all the column names of the class to HTML::Element objects representing form widgets. to_field($field [, $how]) This maps an individual column to a form element. The "how" argument can be used to force the field type into one of "textfield", "textarea" or "select"; you can use this is you want to avoid the automatic detection of has-a relationships. CHANGES
Version 1.x of this module returned raw HTML instead of "HTML::Element" objects, which made it harder to manipulate the HTML before sending it out. If you depend on the old behaviour, set $Class::DBI::AsForm::OLD_STYLE to a true value. MAINTAINER
Tony Bowden ORIGINAL AUTHOR
Simon Cozens BUGS and QUERIES Please direct all correspondence regarding this module to: bug-Class-DBI-AsForm@rt.cpan.org COPYRIGHT AND LICENSE
Copyright 2003-2004 by Simon Cozens / Tony Bowden 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, HTML::Element. perl v5.10.1 2005-09-06 Class::DBI::AsForm(3pm)

Check Out this Related Man Page

Class::DBI::Pg(3pm)					User Contributed Perl Documentation				       Class::DBI::Pg(3pm)

NAME
Class::DBI::Pg - Class::DBI extension for Postgres SYNOPSIS
use strict; use base qw(Class::DBI::Pg); __PACKAGE__->set_db(Main => 'dbi:Pg:dbname=dbname', 'user', 'password'); __PACKAGE__->set_up_table('film'); DESCRIPTION
Class::DBI::Pg automate the setup of Class::DBI columns and primary key for Postgres. select Postgres system catalog and find out all columns, primary key and SERIAL type column. create table. CREATE TABLE cd ( id SERIAL NOT NULL PRIMARY KEY, title TEXT, artist TEXT, release_date DATE ); setup your class. package CD; use strict; use base qw(Class::DBI::Pg); __PACKAGE__->set_db(Main => 'dbi:Pg:dbname=db', 'user', 'password'); __PACKAGE__->set_up_table('cd'); This is almost the same as the following way. package CD; use strict; use base qw(Class::DBI); __PACKAGE__->set_db(Main => 'dbi:Pg:dbname=db', 'user', 'password'); __PACKAGE__->table('cd'); __PACKAGE__->columns(Primary => 'id'); __PACKAGE__->columns(All => qw(id title artist release_date)); __PACKAGE__->sequence('cd_id_seq'); METHODS
set_up_table TABLENAME HASHREF Declares the Class::DBI class specified by TABLENAME. HASHREF can specify options to when setting up the table. ColumnGroup You can specify the column group that you want your columns to be in. $class->set_up_table($table, { ColumnGroup => 'Essential' }); The default is 'All' Primary Overrides primary key setting. This can be useful when working with views instead of tables. pg_version Returns the postgres version that you are currently using. AUTHOR
Daisuke Maki "dmaki@cpan.org" AUTHOR EMERITUS
Sebastian Riedel, "sri@oook.de" IKEBE Tomohiro, "ikebe@edge.co.jp" LICENSE
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::mysql DBD::Pg perl v5.10.1 2006-07-09 Class::DBI::Pg(3pm)
Man Page