FormProcessor code updated

I’ve uploaded a newer version of the “FormProcessor”:http://peter.mapledesign.co.uk/quests/formprocessor.

h3. Changes

* Added support for radio buttons, checkboxes and selects.
* Maybe a few other things I’ve forgotten :-)
h3. Current todo list:

# Write a rule extractor to work from an XML file
# Make it work with select fields with the @multiple@ attribute. This is rather important for me, as one of my projects uses a few of these fields. So what are the current problems? Well
## The code always expects a string rather than an array of fields
## Because the @select@ has to have the name @whatever[]@ when the XML parser goes through the XHTML form looking for fields named @whatever@ that match the contents of the array @$_POST['whatever']@ it doesn’t find any. So the selection does not get remembered, and the field cannot be validated.
# Convert the code to use HTML_SAX - a more liberal parser
# Allow the class to work with forms embedded in a XHTML page, and select which form to work on when more than one form is present in the page.

h3. Features I’d like to add:

* If you have a group of radio buttons inside a @fieldset@, I’d like to be able to add the .invalid class to the fieldset tag rather than the radio buttons.

And a couple of links from “Sitepoint Forums”:http://www.sitepointforums.com on form validation

* “Form Validation (cont.) “:http://www.sitepointforums.com/showthread.php?threadid=121129
* “Form Validation”:http://www.sitepointforums.com/showthread.php?threadid=77563 - with code from Vincent Oostind, but I think his approach is overkill
* “Advanced Form Validation”:http://www.sitepointforums.com/showthread.php?threadid=114185 - A thread by Simon Willison on his FormProcessor class, discussing the best way to handle validation.

On a related note, I stumbled across “dbForm”:http://dbform.sourceforge.net/ today, which is similar to PHPLens (but I think more basic) and of course free. I think it’ll find its way into my latest project…

2 comments ↓

#1 David Lee on 06.28.04 at 12:57 am

Hi Peter,

I’ve been thinking of tackling this myself until I came across a few resources on the web; I’m now thinking it’d be best to use pre-existing code and pass on any improvements I come up with.

I’m writing a web application which will make very heavy use of forms, and has a very tight deadline. Consequently I’m trying to nail down a decision on the form API as quickly as possible.

I’ll download the source today and have a quick look over it. It seems like the closest thing to what I’m after.

If I do end up using it, I’m sure I’ll have some questions for you and hopefully come up with some improvements / suggestions / documentation. I’ll let you know how i go.

Kudos for taking on something so potentially useful :)
regards,
David Lee.

#2 Jim Bewlay on 04.20.06 at 9:12 pm

Hi Peter

I ahve been very impressed with the ovrall appraoch taken over this problem by David.

Although I have been using PHP for several years on and off I don’t pretend to understand how the class works. I am at the moment trying to write a CMS ( I know why bother - there are reasons I won’t bore you with at teh moment) but I would really like to develop the ideas further using xml ect so it’s importantI get to understand how the class actually works.

Starting from the begiining how does the class link to test.php

your help would really be appreciated

regards

JIm Bewlay

Leave a Comment