[Israel.pm] Messing with Forms... Again...

Yuval Yaari yuval at windax.com
Mon Jan 12 01:17:01 PST 2004


Again, I'm trying to simplify the thing I hate most: handling forms.

Usually the 3 steps occur:
1) Display the form
2) Check the submitted values.
     if everything's ok, go to step 3, otherwise, go back to step 1 and
     show the error.
3) Display a thank you message (or show the next part of the form... 
either way, that page will need access to the last POST data)

I would like to simplify everything.

As Pinkhas offered me, the forms won't contain _any_ form validation.

The form validation will be done in mod_perl's handler subroutine.

Then the validation function will either give an error (put it in the 
session, or using pnotes) and the autohandler of the forms will display 
it (so the forms won't contain any code, but the autohandler will) OR 
will redirect to the next page (either a thank you message or the next 
part of the form).

This probably keeps everything clean(er).

Now, since I am familiar with not-being-correct-about-field-names (the 
HTML coder uses FirstName and the Perl coder uses first_name etc)
I would like to create some data-structure to keep this easy.

Also this data strucute should keep some information about:

* The form's next part (URI or something)
* The form's validation function (subroutine reference, the params will 
be passed to it)
* The form's "action" function (or maybe I should keep it inside the 
validation function?)

I also have no idea what's the FORM's ACTION should be (since 
everything's done using the mod_perl handler subroutine).

Any idea about how to implement everything would be appreciated.
Anyone here ever created a big site and wants to share how he 
implemented forms handling?


More information about the Perl mailing list