
Files in this directory
-----------------------
README			This file
former			The script
example.cgi		An example CGI script using former output
some.fd			An example former input file (fd = form description)
some.pm			The output of former

What is it?
-----------
The former script allows you to describe basic form fields (text input,
select/menus and radio buttons) along with validation code for each field.

It will then generate a perl package that you can include from your CGI
script.  This package will create and validate the CGI forms for you.

This is pretty easy/useful, once you learn the basic syntax.

Example
-------
The example included is a simple, fictitious two-page registration form.
The example.cgi is written by the user to handle the form output and decide
how to jump from page to page.

It includes "some.pm" which is easily generated from some.fd:

% former some.fd > some.pm

Try viewing example.cgi through a browser, go through parts of the
registration leaving fields blank and see what errors you encounter,
then look at some.fd to see how it's being created.

.fd Syntax
----------
Okay, this is initially ugly to read, but it's pretty simple:

We start/end forms with:  <form name> .. </form>

And fill it with fields:

  name;Prompt;type type_opts;[err msg];checking expression

And selects/radio buttons:
  <select>
    name;value;optional check
  </select>

Example:
<form page1>
  form_number;1;hidden
  first_name;First Name:;input size='25' maxsize='100';1;
  email;Email:;input size='25' maxsize='100';/\S\@\S+\.\S+/;email must be of form <i>login@somewhere.com</i>
  cost;Cost:;input size='5' maxsize='10';/^\d+$/ && $_;cost must be a number
  <select airport;Airport:>
    none;Where are you flying into?;0
    sfo;SFO
    oak;OAK;$query->{first_name} =~ /mike/;Mike lives in oak
    sjc;SJC
  </select>
  <radio fav_color;Favorite color>
    red;Red;$query->{first_name} =~ /mike/;Only people named Mike like the color red
    green;Green
    blue;Of course, Blue is my favorite color
  </radio>
  next;Next page;submit
</form>

"checking expression" of 1 means the field needs any string entry

Author
------
David Ljung Madison
http://MarginalHacks.com/Contact/

