# man > CGI::FormBuilder::Template::Fast

---
type: CommandReference
command: CGI::FormBuilder::Template::Fast
mode: perldoc
section: 3pm
source: perldoc
---

## Quick Reference
- `my $form = CGI::FormBuilder->new(..., template => { type => 'Fast', root => '/path', define => { form => 'form.txt', field => 'field.txt', invalid_field => 'invalid_field.txt' } });` — Use external FastTemplate files
- `my $form = CGI::FormBuilder->new(..., template => { type => 'Fast', define_nofile => { form => '<html>...', field => '...', invalid_field => '...' } });` — Define templates inline
- `$FIELDS` — Accumulated processed field output, used in the form template
- `$FIELD` — HTML input tag for a single field
- Precedence: `define_nofile` > `define_raw` > `define`

## Name
`CGI::FormBuilder::Template::Fast` — FormBuilder interface to CGI::FastTemplate

## Synopsis
perl
my $form = CGI::FormBuilder->new(
    fields   => \@whatever,
    template => {
        type          => 'Fast',
        root          => '/path/to/templates',
        define        => {
            form           => 'form.txt',
            field          => 'field.txt',
            invalid_field  => 'invalid_field.txt',
        },
        # or define inline
        define_nofile => {
            form => '<html>...$START_FORM...$FIELDS...$END_FORM</html>',
            field => '<tr>$LABEL $FIELD</tr>',
            invalid_field => '<tr>$LABEL $FIELD <span>$ERROR</span></tr>',
        },
    },
);
## Options

### Template Configuration
- `type` — Set to `'Fast'` or `'FastTemplate'` to select this adapter.
- `root` — Root directory for template files (used with `define`).
- `define` — Hash mapping template names (`form`, `field`, `invalid_field`) to file names. External files take precedence over `define_raw` but are overridden by `define_nofile`.
- `define_nofile` — Hash mapping template names to inline template strings. Highest precedence.
- `define_raw` — Same as `define_nofile` but lower precedence; used for legacy compatibility.

### Required Templates
Three templates must be defined:
- `form` — Main form wrapper template.
- `field` — Template for each valid field; output is appended to `$FIELDS`.
- `invalid_field` — Template for fields with validation errors.

### Field Template Variables
- `$NAME` — Field name
- `$FIELD` — HTML input tag
- `$VALUE` — First value
- `$LABEL` — Field label
- `$COMMENT` — Comment text
- `$ERROR` — Error message
- `$REQUIRED` — `'required'` or `'optional'`

### Form Template Variables
- `$TITLE` — Form title
- `$START_FORM` — Opening `<form>` tag
- `$FIELDS` — Accumulated field templates
- `$SUBMIT` — Submit button
- `$RESET` — Reset button
- `$END_FORM` — Closing `</form>` tag
- `$JS_HEAD` — Validation JavaScript code

## See Also
- [CGI::FormBuilder](https://metacpan.org/pod/CGI::FormBuilder)
- [CGI::FormBuilder::Template](https://metacpan.org/pod/CGI::FormBuilder::Template)
- [CGI::FastTemplate](https://metacpan.org/pod/CGI::FastTemplate)