File: README

package info (click to toggle)
libclass-dbi-asform-perl 2.42-7
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 124 kB
  • sloc: perl: 67; makefile: 2
file content (75 lines) | stat: -rw-r--r-- 2,414 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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.