GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  CLASS::DBI::ASFORM (3)

.ds Aq ’

NAME

Class::DBI::AsForm - Produce HTML form elements for database columns

CONTENTS

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 [, CW$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.
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 CLASS::DBI::ASFORM (3) 2005-09-06

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.