man CGI::FormBuilder::Template::Fast () - FormBuilder interface to CGI::FastTemplate
NAME
CGI::FormBuilder::Template::Fast - FormBuilder interface to CGI::FastTemplate
SYNOPSIS
my $form = CGI::FormBuilder->new( fields => \@whatever, template => { type => 'Fast', root => '/path/to/templates', # use external files define => { form => 'form.txt', field => 'field.txt', invalid_field => 'invalid_field.txt', }, # or define inline define_nofile => { form => '<html><head></head><body>$START_FORM <table>$FIELDS</table>$SUBMIT $END_FORM</body></html>', # etc. }, }, );
DESCRIPTION
This engine adapts FormBuilder to use CWCGI::FastTemplate. Please read these docs carefully, as the usage differs from other template adapters in several important ways.
You will need to define three templates: CWform, CWfield, and CWinvalid_field. You can use CWdefine to point to external files (which is the recommended CWCGI::FastTemplate style), or CWdefine_nofile/ CWdefine_raw to define them inline. The templates in CWdefine_nofile take precedence over CWdefine_raw, and both of these take precedence over CWdefine.
my $form = CGI::FormBuilder->new( # ... template => { type => 'FastTemplate', root => '/path/to/templates', define => { form => 'form.txt', field => 'field.txt', invalid_field => 'invalid_field.txt', }, # or, you can define templates directly define_nofile => { form => '<html><head></head><body>$START_FORM<table>' '$FIELDS</table>$SUBMIT $END_FORM</body></html>', # etc. }, }, # ... );
If you use CWdefine with external templates, you will probably also want to define your template root directory with the CWroot parameter.
Within each of the field templates, the following variables are available:
$NAME # $field->name $FIELD # $field->tag (HTML input tag) $VALUE # $field->value (first value only!) $LABEL # $field->label $COMMENT # $field->comment $ERROR # $field->error $REQUIRED # $field->required ? 'required' : 'optional'
All the fields are processed in sequence; valid fields use the CWfield template, and invalid fields the CWinvalid_field template. The result from each of these is appended into the CW$FIELDS variable, which you should use in your CWform template. In the CWform template, you also have access to these variables:
$TITLE # title of the form $START_FORM # opening form tag $SUBMIT # the submit button $RESET # the reset button $END_FORM # closing form tag $JS_HEAD # validation JavaScript
Note that since CWCGI::FastTemplate doesn't use anything other than simple scalar variables, there are no variables corrosponding to the lists that other engines have (e.g. CWfields or CWoptions lists in CWTT2 or CWText::Template).
SEE ALSO
CGI::FormBuilder, CGI::FormBuilder::Template, CGI::FastTemplate
AUTHOR
Copyright (c) 2005 Peter Eichman <peichman@cpan.org>. All Rights Reserved.
Maintained as part of CWCGI::FormBuilder by Nathan Wiger <nate@sun.com>.
This module is free software; you may copy this under the terms of the GNU General Public License, or the Artistic License, copies of which should have accompanied your Perl kit.