[RFC] HTML::Formit.pm

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

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.

    HTML::Formit - A CGI Form Generator

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

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


     use warnings;
     use strict;
     use CGI (':standard');
     use HTML::Formit;
     my $p = new HTML::Formit;
    '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?
    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.

    Mark Leeds

    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.

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

    2005 Mark Leeds

Site Timeline