Click here to get back home

[RFC] HTML::Formit.pm

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
[RFC] HTML::Formit.pm mjl69 02-16-2005
Posted by mjl69 on February 16, 2005, 9:52 pm
Please log in for more thread options


I have written a humble little module that I am planning to put on CPAN.
Please take a look at the following documentation and tell me what you think.
I have found it to be useful in my own work.


NAME
HTML::Formit - A CGI Form Generator

SYNOPSIS
Generate simple forms with HTML widgets for use with your CGI programs.

DESCRIPTION
HTML::Formit is a class that helps to generate useful HTML forms that are
neatly lined up in a table.

Usage:

#!/usr/bin/perl
use warnings;
use strict;
use CGI (':standard');
use HTML::Formit;

my $p = new HTML::Formit;
$p->load([
        'name',
        'date of birth',
        'life story::textarea::4::50',
        'favorite ice cream::radio_group::vanilla::chocolate',
        'favorite parents::checkbox_group::mom::dad',
        'favorite color::scrolling_list::red::blue::pink::purple::green'
        ]);
print start_form();
print $p->generate;
print submit(-name=>'add');
print end_form();

#or you can load from a file...
my $q = new HTML::Formit;
$p->load('data.dat', %defaults);#the name of your data file with form
structure data

The optional %defaults ref should contain keys as field names and
default values to insert #this will trigger override for the fields
listed and use these values.

The load method loads data for the form structure which must be in the
following format:

field1::textarea::10::30::Hello, how are::you?
field2::textfield::50::Hello, I am::fine!
field3::radio_group::I am::fine::too
field4::checkbox_group::I::am::a robot
field5::popup_menu::do you::want to::be a::chicken?
field6::scrolling_list::5::yes::I::do!

The values on each line are separated by '::'. You cannot use :: in a
string because of this. The first value is the name of the field. The
second is the type of widget you want which must be one of the 5 listed
above. If it is not, textfield will be used by default. If it is a
textarea, the 3rd and 4th values on the line are the row and column
values. The remainder of the line is the default text, if any, that will
go in the textarea. Any ::'s mixed in with this text will convert to
spaces. A textfield has its size as the third value. For the other three
types, each item separated by ::'s will be a different choice given.
Experiment with it to get the hang of it. If you just pass a reference
to an array of words, you will get a list of textfields with these
labels by default.

AUTHOR
Mark Leeds

BUGS
If you leave out the row and col values for textarea or the length value
for textfield and you also want default text, you may lose part of your
default text as it will be assumed to be these values.

SEE ALSO
http://stein.cshl.org/WWW/software/CGI/

COPYRIGHT
2005 Mark Leeds


Similar ThreadsPosted
[RFC] HTML::Dashboard (Spreadsheet-like formatting for HTML tables) April 16, 2007, 4:50 pm
HTML ---> PDF October 27, 2004, 2:13 am
HTML::TableExtract October 11, 2004, 9:30 pm
[RFC] HTML::FormatData May 13, 2005, 2:51 pm
[RFC] HTML::CheckArgs May 13, 2005, 2:49 pm
HTML::TableExtractor November 30, 2004, 6:42 am
CGI.pm and HTML tables December 15, 2004, 12:34 am
HTML::Mason March 7, 2005, 7:45 am
HTML parsing March 21, 2005, 3:24 pm
Possible bug in HTML::BBCode? November 1, 2005, 9:37 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap