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::Plugin::RetrieveAll(3pm)			User Contributed Perl Documentation		      Class::DBI::Plugin::RetrieveAll(3pm)

NAME
Class::DBI::Plugin::RetrieveAll - more complex retrieve_all() for Class::DBI SYNOPSIS
use base 'Class::DBI'; use Class::DBI::Plugin::RetrieveAll; my @by_date = My::Class->retrieve_all_sorted_by("date"); # or __PACKAGE__->retrieve_all_sort_field('date'); my @by_date = My::Class->retrieve_all; DESCRIPTION
This is a simple plugin to a Class::DBI subclass that allows for simple sorting of the results of a retrieve_all(). There are two main ways to use this. Firstly, we create a new method 'retrieve_all_sorted_by' which takes an argument of how to sort. We also add a method for 'retrieve_all_sort_field' that sets a default field that any retrieve_all() will use for sorting. METHODS
retrieve_all_sorted_by my @by_date = My::Class->retrieve_all_sorted_by("date"); This method will be exported into the calling class, and allows for retrieving all the objects of the class, sorted by the given column. The argument given will be passed straight through to the database 'as is', and is not checked in any way, so an error here will usually in an error from the database, rather than Class::DBI itself. This makes it possible to pass more complex ORDER BY clauses through: my @by_date = My::Class->retrieve_all_sorted_by("date DESC, reference_no"); retrieve_all_sort_field __PACKAGE__->retrieve_all_sort_field('date'); This method changes the default retrieve_all() in the Class to be auto-sorted by the field given. Again this will be passed through directly, so you can have complex ORDER BY clauses. AUTHOR
Tony Bowden BUGS and QUERIES Please direct all correspondence regarding this module to: bug-Class-DBI-Plugin-RetrieveAll@rt.cpan.org COPYRIGHT and LICENSE Copyright (C) 2004-2006 Kasei. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.0 2006-01-16 Class::DBI::Plugin::RetrieveAll(3pm)
Man Page