1CGI::FormBuilder::TemplUasteer::CFoansttr(i3b)uted PerlCDGoIc:u:mFeonrtmaBtuiiolnder::Template::Fast(3)
2
3
4
6 CGI::FormBuilder::Template::Fast - FormBuilder interface to
7 CGI::FastTemplate
8
10 my $form = CGI::FormBuilder->new(
11 fields => \@whatever,
12 template => {
13 type => 'Fast',
14 root => '/path/to/templates',
15 # use external files
16 define => {
17 form => 'form.txt',
18 field => 'field.txt',
19 invalid_field => 'invalid_field.txt',
20 },
21 # or define inline
22 define_nofile => {
23 form => '<html><head></head><body>$START_FORM
24 <table>$FIELDS</table>$SUBMIT $END_FORM</body></html>',
25 # etc.
26 },
27 },
28 );
29
31 This engine adapts FormBuilder to use "CGI::FastTemplate". Please read
32 these docs carefully, as the usage differs from other template adapters
33 in several important ways.
34
35 You will need to define three templates: "form", "field", and
36 "invalid_field". You can use "define" to point to external files (which
37 is the recommended "CGI::FastTemplate" style), or "define_nofile"/
38 "define_raw" to define them inline. The templates in "define_nofile"
39 take precedence over "define_raw", and both of these take precedence
40 over "define".
41
42 my $form = CGI::FormBuilder->new(
43 # ...
44 template => {
45 type => 'FastTemplate',
46 root => '/path/to/templates',
47 define => {
48 form => 'form.txt',
49 field => 'field.txt',
50 invalid_field => 'invalid_field.txt',
51 },
52 # or, you can define templates directly
53 define_nofile => {
54 form => '<html><head></head><body>$START_FORM<table>'
55 '$FIELDS</table>$SUBMIT $END_FORM</body></html>',
56 # etc.
57 },
58 },
59 # ...
60 );
61
62 If you use "define" with external templates, you will probably also
63 want to define your template root directory with the "root" parameter.
64
65 Within each of the field templates, the following variables are
66 available:
67
68 $NAME # $field->name
69 $FIELD # $field->tag (HTML input tag)
70 $VALUE # $field->value (first value only!)
71 $LABEL # $field->label
72 $COMMENT # $field->comment
73 $ERROR # $field->error
74 $REQUIRED # $field->required ? 'required' : 'optional'
75
76 All the fields are processed in sequence; valid fields use the "field"
77 template, and invalid fields the "invalid_field" template. The result
78 from each of these is appended into the $FIELDS variable, which you
79 should use in your "form" template. In the "form" template, you also
80 have access to these variables:
81
82 $TITLE # title of the form
83 $START_FORM # opening form tag
84 $SUBMIT # the submit button
85 $RESET # the reset button
86 $END_FORM # closing form tag
87 $JS_HEAD # validation JavaScript
88
89 Note that since "CGI::FastTemplate" doesn't use anything other than
90 simple scalar variables, there are no variables corrosponding to the
91 lists that other engines have (e.g. "fields" or "options" lists in
92 "TT2" or "Text::Template").
93
95 CGI::FormBuilder, CGI::FormBuilder::Template, CGI::FastTemplate
96
98 Copyright (c) 2005-2006 Peter Eichman <peichman@cpan.org>. All Rights
99 Reserved.
100
101 Maintained as part of "CGI::FormBuilder" by Nate Wiger
102 <nate@wiger.org>.
103
104 This module is free software; you may copy this under the terms of the
105 GNU General Public License, or the Artistic License, copies of which
106 should have accompanied your Perl kit.
107
108
109
110perl v5.12.0 2007-03-02CGI::FormBuilder::Template::Fast(3)