NAME
HTML::FillInForm - Populates HTML Forms with CGI data.
DESCRIPTION
This module automatically inserts data from a previous HTML form into the HTML input, textarea and select tags. It is a subclass of HTML::Parser and uses it to parse the HTML and insert the values into the form tags.
One useful application is after a user submits an HTML form without filling out a required field. HTML::FillInForm can be used to redisplay the HTML form with all the form elements containing the submitted info.
SYNOPSIS
This examples fills data into a HTML form stored in $htmlForm
from CGI parameters that are stored in $q
. For example, it will set the value of any "name" textfield to "John Smith".
my $q = new CGI;
$q->param("name","John Smith");
my $fif = new HTML::FillInForm;
my $output = $fif->fill(scalarref => \$html,
fobject => $q);
METHODS
- new
-
Call
new()
to create a new FillInForm object:$fif = new HTML::FillInForm;
- fill
-
To fill in a HTML form contained in a scalar
$html
:$output = $fif->fill(scalarref => \$html, fobject => $q);
Returns filled in HTML form contained in
$html
with data from$q
.$q
is required to have aparam()
method that works like CGI'sparam()
.$output = $fif->fill(scalarref => \$html, fdat => \%fdat);
Returns filled in HTML form contained in
$html
with data from%fdat
. To pass multiple values using%fdat
use an array reference.Alternately you can use
$output = $fif->fill(arrayref => \@array_of_lines, fobject => $q);
and
$output = $fif->fill(file => 'form.tmpl', fobject => $q);
CALLING FROM OTHER MODULES
Apache::PageKit
To use HTML::FillInForm in Apache::PageKit is easy. It is automatically called for any page that includes a <form> tag.
Apache::ASP v2.09 and above
HTML::FillInForm is now integrated with Apache::ASP. To activate, use
PerlSetVar FormFill 1
$Response->{FormFill} = 1
Apache::ASP v2.08 and below
To use HTML::FillInForm, put the following in global.asa
sub fillin {
my $args = shift;
my $html = shift;
my $fif = new HTML::FillInForm;
my $output = $fif->fill(
scalarref => \$html,
fdat => $Apps::Param,
);
$Response->Write($output);
}
Note $Apps::Param is set to either the querystring or form data. Replace with $Request->QueryString or $Request->Form if you wish.
Then put something like this in your apache configuration:
XMLSubsMatch fillin
Finally, surround your forms like this:
<fillin>
<form>
<input name="myfield">
</form>
</fillin>
See http://forum.swarthmore.edu/epigone/modperl/malskalko for more details.
SEE ALSO
VERSION
This documentation describes HTML::FillInForm module version 0.10.
BUGS
This module has not been tested extensively. Please submit any bug reports to tjmather@anidea.com.
NOTES
Requires Perl 5.005 and HTML::Parser version 3.08.
I wrote this module because I wanted to be able to insert CGI data into HTML forms, but without combining the HTML and Perl code. CGI.pm and Embperl allow you so insert CGI data into forms, but require that you mix HTML with Perl.
AUTHOR
(c) 2000 Thomas J. Mather, tjmather@alumni.princeton.edu
All rights reserved. This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
CREDITS
Fixes, Bug Reports, Docs have been generously provided by:
Patrick Michael Kane
Tom Lancaster
Ade Olonoh
Tatsuhiko Miyagawa
Paul Lindner
Thanks!